Stap 3: Testen van Code
gpio importeren
importeren van tijd slaap
led_pin = "gpio2" sensor_pin = "gpio4"
def delay(ms):
Sleep(1.0*MS/1000)
def Setup:
gpio.pinMode (led_pin, gpio. UITVOER)
gpio.pinMode (sensor_pin, gpio. INGANG)
afdrukken "Linker LED Pin: D2 \n Hall Sensor Pin: D4" def loop:
while(1):
if(GPIO.digitalRead(sensor_pin)):
gpio.digitalWrite (led_pin, gpio. HOOG)
anders:
gpio.digitalWrite (led_pin, gpio. LAAG) Setup loop