Hello guys, i found this site very helpful to my project, i hope someone can help me regarding my project.
I'm creating a code for lighting 3 bulbs using a relay module(4 channel) and 3 push buttons, but couldn't make it work.
After I press the first pushbutton I want light1 to be energized for 20s,
Then after i press button2, light2 will be energized for 30s,
After i press button3, light3 will be energized for 40s.
I hope someone can help me creating a code for this project.
Thanks.
I would make sure your hardware is connected properly first. For example, to connect your 4 relay module properly, it needs to have the jumper removed. There'll be 3 pins exposed here. Then you'll need to connect a separate DC power supply to the JD-VCC terminal and GND terminal. The only connections to the Arduino is IN1, IN2, IN3, IN4, VCC. There is no GND connection to your Arduino. There is no GND connection to your Arduino. Did I say that already?
Anyways, a diagram or description of your connections would be helpful.
Suggestion:
Start simply and get the code right first.
Instead of connecting the relay module, simply connect leds (with series resitors) to the same pins.
Write some test code to latch one of the leds for a certain amount of time. Then expand from there.
Here is an example