Hello,
Im making remote switch and volume control via servo for my amplifier, I also added 7 leds that sweep left when volume goes down and sweep right when volume goes up. Now I have two problems that I can
t figure out.
First is how do I read servo angle and light leds according to it.
What I would like to achieve:
Servo at 0 - 25°: Led1 is on
Servo at 26 - 51°: Leds1,2 are on
Servo at 52- 77°: Leds1,2,3 are on
Servo at 78- 103°: Leds12,3,4 are on
Servo at 79 - 104°: Leds1,2,3,4,5 are on
Servo at 105 - 130°: Leds1,2,3,4,5,6 are on
Servo at 131 - 180°: Leds1,2,3,4,5,6,7 are on
I just need some commads to read servo angle and digitalwrite if angle = x.
Now I want to turn on leds when I let go of the volume + or - button and I want them to stay on for lets say 3 seconds.
I know how to turn them off after 3 sec (delay then digitalwrite LOW), no problem.
But how can I turn them on after I release the volume buttons?
How do I make the script to turn on leds when case was 0x10 or 0x11 and it isn`t anymore because I released the button?
I cant just continue with commands after my servo movement, led sweep loop under case(0x10) or case(0x11) because as long as I hold the button leds must sweep and servo must move.
Now the other problem:
Once I release the button I get some delay because of delay commands inside my led sweep code. Nothing wrong, but sometimes when I release the button it still does one led sweep and one servo step. I want to break the loop under case(0x10) and case(0x11) as soon as I release the button.
Thank you
dela vse plus duble ledice.txt (3.38 KB)