Hi Guys,
i'm quite new in Arduino but getting along with it pretty well.
Currently i'm working on a simple project.
If the trigger (dry contact input) is high the lights should fade in and stay on.
if the input goes low the lights should fade out and stay out.
I've worked with DmxSimple to create the project. However, DmxSimple is always fading on and off.
I'm search for a solution to make one single fade(instead of on/off/on/off/on/off) after the fade the light should stay until the situation changes.
Here is my code so far, please notice this is for 2 lamps (if input is high one light should fade in and the other should fade out. If input is low then the other way around.)
/* Doloris door-fade(3x horizontal doors)
*
*
- Function of showfile ==
- input in door detects situation (open or closed)
- When door opens full a sensor (buttonPin2) is triggered.
- When triggered; one light will fade off and the other will turn on.
- end *
*/
#include <DmxSimple.h>
const int buttonPin = 2;
int buttonState = 0;
void setup() {
DmxSimple.usePin(3);
DmxSimple.maxChannel(3);
Serial.begin(9600);
pinMode(buttonPin, INPUT);
}
void loop() {
buttonState = digitalRead(buttonPin);
int brightness;
if (buttonState == HIGH) {
for(brightness = 0; brightness <= 255; brightness++){
DmxSimple.write(1, 50);
delay (10);
}
for(brightness = 255; brightness >= 0; brightness--) {
DmxSimple.write(2, 0);
delay(10);
}
}
else {
for(brightness = 0; brightness <= 255; brightness++){
DmxSimple.write(2, 50);
delay (10);
}
for(brightness = 255; brightness >= 0; brightness--) {
DmxSimple.write(1, 0);
delay(10);
}
}
}