Advertisement
RuiViana

Untitled

Apr 22nd, 2015
368
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. int LAMP = 3;
  2. int dimming = 10;
  3. int i = 0;
  4.  
  5. String str;
  6.  
  7. void setup()
  8. {
  9. Serial.begin(9600);
  10. delay(300);
  11.  
  12. pinMode(LAMP, OUTPUT);
  13.  
  14. attachInterrupt(0, zero_crosss_int, RISING);
  15. }
  16.  
  17. void loop()
  18. {
  19. Serial.println(dimming);
  20. if(Serial.available() > 0)
  21. {
  22. str = Serial.readStringUntil('\n');
  23. dimming = str.toInt();
  24. dimming= dimming*1.2;
  25. if (dimming <10) dimming = 10;
  26. Serial.println(dimming);
  27. }
  28. delay(100);
  29. }
  30.  
  31. void zero_crosss_int()
  32. {
  33. int dimtime = (65 * dimming);
  34. delayMicroseconds(dimtime);
  35. digitalWrite(LAMP, HIGH);
  36. delayMicroseconds(8.33);
  37. digitalWrite(LAMP, LOW);
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement