diff --git a/2_BUTTON/button_function.py b/2_BUTTON/button_function.py index 00760bc..0aa0424 100644 --- a/2_BUTTON/button_function.py +++ b/2_BUTTON/button_function.py @@ -1,11 +1,10 @@ from gpiozero import Button +from gpiozero import LED from signal import pause -def say_hello(): - print("Hello!") - +led_green = LED(18) button = Button(23) -button.when_pressed = say_hello + led_green.toggle() pause() diff --git a/2_BUTTON/button_turnOnLED.py b/2_BUTTON/button_turnOnLED.py new file mode 100644 index 0000000..c300e0a --- /dev/null +++ b/2_BUTTON/button_turnOnLED.py @@ -0,0 +1,11 @@ +from gpiozero import Button +from signal import pause + +def say_hello(): + print("Hello!") + +button = Button(23) + +button.when_pressed = say_hello + +pause()