Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int LAMP = 3;
- int dimming = 10;
- int i = 0;
- String str;
- void setup()
- {
- Serial.begin(9600);
- delay(300);
- pinMode(LAMP, OUTPUT);
- attachInterrupt(0, zero_crosss_int, RISING);
- }
- void loop()
- {
- Serial.println(dimming);
- if(Serial.available() > 0)
- {
- str = Serial.readStringUntil('\n');
- dimming = str.toInt();
- dimming= dimming*1.2;
- if (dimming <10) dimming = 10;
- Serial.println(dimming);
- }
- delay(100);
- }
- void zero_crosss_int()
- {
- int dimtime = (65 * dimming);
- delayMicroseconds(dimtime);
- digitalWrite(LAMP, HIGH);
- delayMicroseconds(8.33);
- digitalWrite(LAMP, LOW);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement