Hi guys, i try to make AC dimmer, for now work perfect but reading sensor values is exactly opposite of my needs,when voltage on sensor pin increases, lamp glow decrease. I want when voltage on sensor pin increase light increase too. Here is my code, may be answer is some where in map functions, any suggestions?
[
#define triacPulse 5
int val;
void setup() {
pinMode(2, INPUT);
digitalWrite(2, HIGH); // pull up
pinMode(triacPulse, OUTPUT);
}
void loop() {
attachInterrupt(0, acon, FALLING);
void acon()
{
delayMicroseconds((analogRead(0) * 6) + 1000);
digitalWrite(triacPulse, HIGH);
delayMicroseconds(200);
digitalWrite(triacPulse, LOW);
}