File tree Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Original file line number Diff line number Diff line change 1+ # SPDX-FileCopyrightText: 2023 Liz Clark for Adafruit Industries
2+ #
3+ # SPDX-License-Identifier: MIT
4+
5+ import time
6+ import board
7+ from digitalio import DigitalInOut , Direction , Pull
8+
9+ ir = DigitalInOut (board .D5 )
10+ ir .direction = Direction .INPUT
11+ ir .pull = Pull .UP
12+
13+ while True :
14+ if not ir .value :
15+ print ("object detected!" )
16+ else :
17+ print ("waiting for object..." )
18+ time .sleep (0.01 )
Original file line number Diff line number Diff line change 1+ // SPDX-FileCopyrightText: 2024 Liz Clark for Adafruit Industries
2+ //
3+ // SPDX-License-Identifier: MIT
4+
5+ void setup () {
6+ // start serial connection
7+ Serial.begin (115200 );
8+ pinMode (5 , INPUT_PULLUP);
9+
10+ }
11+
12+ void loop () {
13+ int sensorVal = digitalRead (5 );
14+
15+ if (sensorVal == LOW) {
16+ Serial.println (" object detected!" );
17+ } else {
18+ Serial.println (" waiting for object.." );
19+ }
20+ delay (200 );
21+ }
You can’t perform that action at this time.
0 commit comments