I only started programming on my Rpi this past week, I've never programmed before, and I'm making the most of my lockdown time by keeping my brain engaged.
I Have a Rpi Zero WH connected to a breadboard and 8 LED's (red, amber, green and blue)
Following guides etc I managed to get them to switch on and off, and modified the program myself so that alternate LED's switch on and off.
The project I have in mind requires the LED's to blink at differing speeds at the same time as some of the other LED's are on or blinking at a different speed. Eventually I want to have sound files playing along with the LED's (It's for a diorama that I am building).
As I said, I only started this past week, and have searched but am struggling to find an example of code that I could use/modify to allow me to do what I need to do.
Any help/pointers would be appreciated, I am using Thonny on the RPi to write the code.
Here's the code I have modified from the standard GPIO LED on/off script
I Have a Rpi Zero WH connected to a breadboard and 8 LED's (red, amber, green and blue)
Following guides etc I managed to get them to switch on and off, and modified the program myself so that alternate LED's switch on and off.
The project I have in mind requires the LED's to blink at differing speeds at the same time as some of the other LED's are on or blinking at a different speed. Eventually I want to have sound files playing along with the LED's (It's for a diorama that I am building).
As I said, I only started this past week, and have searched but am struggling to find an example of code that I could use/modify to allow me to do what I need to do.
Any help/pointers would be appreciated, I am using Thonny on the RPi to write the code.
Here's the code I have modified from the standard GPIO LED on/off script
import RPi.GPIO as GPIO import time GPIO.setwarnings(False) GPIO.setmode(GPIO.BCM) GPIO.setup(14,GPIO.OUT) GPIO.setup(15,GPIO.OUT) GPIO.setup(18,GPIO.OUT) GPIO.setup(23,GPIO.OUT) GPIO.setup(24,GPIO.OUT) GPIO.setup(25,GPIO.OUT) GPIO.setup(8,GPIO.OUT) GPIO.setup(7,GPIO.OUT) while True: GPIO.output((((14, 23, 24, 7))), True) #red and green LED on time.sleep(.5) GPIO.output((((14, 23, 24, 7))), False) #red and green LED off time.sleep(.5) GPIO.output((((15, 18, 8, 25))), True) #amber and blue LED on time.sleep(.5) GPIO.output((((15, 18, 8, 25))), False) #amber and blue LED off time.sleep(.5)