Should this code work? Arduino Mega 2560. Solid state relay on PIN 30 and zero crossing input on PIN2 (interrupt 0). requestValue should be between 0 and 255. My lightbulb is just flashing about twice a second. If I change OCR3A to 1280 or 2560, then lightbulb is a lot dimmer but still flashing.
volatile int counterValue; volatile int requestValue1;
EDIT: Got this. Interrupt pin didn't get its signal. But now, requestValue=255 should be very dim and it is. 0 should be brightest, but it's not. Brightest seems to be around 120. requestValue around 60-100 is flickering. 40 and 20 are pretty dim, but I can see no difference in light output. Can anybody give some advice, what could be improved?
Also inputs don't react on every push. It skips some button pushes. If I disable dimmer, everything is fine. What could be causing this? I have many buttons and none of them is working fine on first press.
I did it with counter that increase every loop cycle and then used modulo to decide, when I should move to next step. Then I came here and You suggested the same thing. I think I somehow subconsciously read this thread. Program without delay works with 1 strip. Actually I can't say it's without delay, because I use one delay in the end of loop. Otherwise my counter would increase too fast and I must use bigger numbers with modulo. Now I should probably make WS2801 array and try to calculate functions for them.
I have 3 strips with different lengths. I want to use same color run for all of them. I want all strips start and finish at the same time. But if they are different length, they need to have different speeds. And without delay. All strips must start from the beginning and go pixel after pixel next colour. Like the first run in this video.
I have different strips on different pins. It's not one long strip. I send 3 long strings of data, not one. I could send all update commands at the same time.
Or I could also use some chip, that takes 1 SPI input and splits it to multiple outputs that I could configure. Let's say I have 300 pixels. 1-300 goes to input. 1-100 data goes to output 1 101-200 data goes to output 2 210-300 data goes to output 3
I want to use colorWipe-like function but without delay. I want to light up all strips beginning from one end and filling up to the other. I want to use one function, that takes each instance of the class from array maybe. What aray should I use and is it possible to put strip1, strip2 and strip3 in an array? I'd also like, if it takes same amount of time with 100 pixels and with 25 pixels. 100 pixel strip must run 4 times faster. I also want to be able to change speed, color. And make more cool functions if I can figure out something.
And I want to make different programs run at the same time. At the moment I have for loops for each strip and they run one after the other. I'd like if they run at the same time. All strips have different number of pixels. Is it possible somehow?
1 way communication was working, but it had 1-2 second delay between pushing button on one Arduino and lighting a led on the other Arduino. I tried with 2 variables and both of them changed values. Currently not working 2 way code isn't changing any variable. I'm afraid I am doing something fundamentally wrong making it 2 way, but I can't figure out, what it is.
I already have program that works on Arduino1. It uses some variables to set output status. Now I need to change those same variables with Arduino2 that has ethernet shield connected to it. I want to change output statuses with direct inputs on Arduino1 and ethernet requests on Arduino2. Arduino2 also must monitor those variables and output their statuses. Arduino1 should always have higher priority. If time between changing same variable on both Arduinos in less than 3 seconds, then change should work only on Arduino1. If Arduino1 changes output status and after 3 seconds Arduino2 changes the same output status, then Arduino2 should take priority. All physical outputs are on Arduino1 and it does not have spare pins. I could get serial or I2C link, but that's all I have. I can't connect ethernet module to Arduino1.