Add initial files for the HH Hacking 101 - code and infos about board will follow soon

This commit is contained in:
2023-01-17 01:51:29 +01:00
parent a0f4013f75
commit f723aecc9d
9 changed files with 711 additions and 2 deletions

View File

@@ -0,0 +1,55 @@
## Simple Button and LED test
# yellow led will blink
# red + green will be off button is pressed
from machine import Pin
import time
## define led pins
led_gr_p = 21
led_re_p = 22
led_ye_p = 17
## define switch pins
sw1_p = 32
sw2_p = 33
## init leds
led_gr = Pin(led_gr_p, Pin.OUT)
led_gr.off() # switch on led - inverted logic!
led_re = Pin(led_re_p, Pin.OUT)
led_re.off() # switch on led - inverted logic!
led_ye = Pin(led_ye_p, Pin.OUT)
led_ye.off() # switch on led - inverted logic!
## int buttons (pull-up)
sw1 = Pin(sw1_p, Pin.IN)
sw2 = Pin(sw2_p, Pin.IN)
while True:
if sw1.value():
print("sw1 true")
led_re.on()
#led_ye.on()
else:
print("sw1 false")
led_re.off()
#led_ye.off()
if sw2.value():
print("sw2 true")
led_gr.on()
else:
print("sw2 false")
led_gr.off()
# toggle led
if led_ye.value():
led_ye.off();
else:
led_ye.on();
time.sleep(0.5)