Led

Guys I want to control 4 led clusters, with a tact switch. I want it such that when I first press the tact switch, the first cluster slowly brightens up and then fade to zero brightness, after some time the second cluster brightens up and stay there then after some time third cluster should light up and so on. And by pressing the tact switch it all start from beginning. I have a good understanding on hardware side but I don't know how to code it.. I've been trying to combine some example code but so far it isn't workin. Please urgently help me, I need to get this done by the day after tomorrow. Idk why I can't use the forum using my Mac, so I'm unable to post the code. Please help me guys. I need the code urgently

haiderrizvi:
Guys I want to control 4 led clusters, with a tact switch. I want it such that when I first press the tact switch, the first cluster slowly brightens up and then fade to zero brightness, after some time the second cluster brightens up and stay there then after some time third cluster should light up and so on. And by pressing the tact switch it all start from beginning. I have a good understanding on hardware side but I don't know how to code it.. I've been trying to combine some example code but so far it isn't workin. Please urgently help me, I need to get this done by the day after tomorrow. Idk why I can't use the forum using my Mac, so I'm unable to post the code. Please help me guys. I need the code urgently

Pass off someone else's work as your own.

Just guide me a little

I've been trying to combine some example code

Show us.

Here have a look at the code that I've been able to combine from examples.. I'm sorry it's a screenshot but I can't access this forum from my Mac so I had to take a screen shot.. Please find the attachment and guide me

I'm sorry it's a screenshot but I can't access this forum from my Mac so I had to take a screen shot..

My turn to not understand something.

What is working and what isn't working? Can you fade the built-in pin-13 LED? (It looks like your current code simply turns the pin-13 LED on & off according to the button state.)

Your code also fades up & down pin-9. Does that work? Your code is only controlling one output... You need 3 more to PWM-control 3 more outputs for the other 3 clusters.

I have a good understanding on hardware side...

Are you sure your LED cluster is dimmable with PWM?

Can you dim one of them? Can you turn them on & off with the Arduino?

You might need to tell us something more about your hardware... And, it's probably easier to develop your code with 4 regular LEDs (with their current-limiting resistors) before connecting the clusters.

I've been trying to combine some example code but so far it isn't workin.

Combining /merging code NEVER works! :wink: You've got to combine concepts and that means you have to understand the concepts in the example code...

The program is not "difficult" to write (if the hardware really works). But I have no idea if you can learn enough programming to complete it by tomorrow.

I'm able to to fade the pin 13 led, what I can't do is to make it go only one cycle of turning all the way up and and then down. And I am developing the code with regular LEDs. I can turn my LEDs on or off with arduino. To control the cluster I am usIng tip122 Darlington transistor.

I'm able to to fade the pin 13 led, what I can't do is to make it go only one cycle of turning all the way up and then down

The code in your screenshot should continuously repeat that cycle. I don't see anything to stop or "pause" the main loop after one cycle.

. I can turn my LEDs on or off with arduino.

Good! If they are connected to PWM pins, you should also be able to fade them. You just need to repeat the working code that that fades the pin-13 LED but with different variables that "point to" the other LED pins.

Once you have the fade-sequence and timing done, you need to add another loop at the start of your main loop. That loop should just sit there looping and reading the button until you press the button. When you press the button, break out of the loop and continue to code that fades the LEDs. I'd probably use a [u]while() loop[/u].

...You've got code at the bottom of the loop to read a button, but as you've described your requirements you need to check the button state before you start the fade-sequence.

To control the cluster I am usIng tip122 Darlington transistor.

What happens when you connect that circuit to pin-13? If the cluster dims along with the pin-13 LED, good! If not, we'll need to see your schematic in order to help you.

I am not sure how to stop or pause main loop, there's only one cluster though I want to go up and then down and stay there, for all the others I want them to go up and then stay steady until I press the button once again to start the sequence again. And yes pin 13 does fade my led cluster.

Look at the Example of flashing lots of LEDs and using the library to control your LED.

Should I include the code for first cluster in setup() function, then it'll only run once?a

Hi,

Can you attach the sketch file?

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png or pdf?

Tom.... :slight_smile: