Skip to content

Commit 8725a2f

Browse files
authored
Create PhysicalPixel.py
1 parent ded2116 commit 8725a2f

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

04.Communication/PhysicalPixel.py

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
"""
2+
Physical Pixel
3+
4+
An example of using the Arduino board to receive data from the computer. In
5+
this case, the Arduino boards turns on an LED when it receives the character
6+
'H', and turns off the LED when it receives the character 'L'.
7+
8+
The data can be sent from the Arduino Serial Monitor, or another program like
9+
Processing (see code below), Flash (via a serial-net proxy), PD, or Max/MSP.
10+
11+
The circuit:
12+
- LED connected from digital GPIO27 to ground
13+
"""
14+
15+
from machine import Pin
16+
from time import sleep
17+
18+
led = Pin(27, Pin.OUT) # the pin that the LED is attached to
19+
20+
while True:
21+
incomingByte = input("Enter a letter: ")
22+
# if it's a capital H turn on the LED:
23+
if incomingByte == "H":
24+
led.value(1)
25+
# if it's an L turn off the LED:
26+
if incomingByte == "L":
27+
led.value(0)
28+
29+
sleep(0.005)

0 commit comments

Comments
 (0)