KRITSADA icon

Pin Read digital example

KRITSADA | PRO | 10/28/19 09:39:35 AM UTC | 0 ⭐ | 550 👁️ | Never ⏰ | []
Python |

670 B

|

None

|

0 👍

/

0 👎

#PLAYER
from microbit import *
import radio
 
radio.on()
radio.config(channel=30)
# display.off()
 
POSITION_1 = '1'
POSITION_2 = '2'
POSITION_3 = '3'
POSITION_4 = '4'
 
#change pins based on wiring
def send_position():
    if pin0.read_digital():
        radio.send(POSITION_1)
        display.show("1")
        sleep(500)
    if pin1.read_digital():
        radio.send(POSITION_2)
        display.show("2")
        sleep(500)
    if pin2.read_digital():
        radio.send(POSITION_3)
        display.show("3")
        sleep(500)
    display.clear()
    """
    if pin3.read_digital():
        radio.send(POSITION_4)
"""
 
 
while True:
    send_position()

Comments