Advertisement
safwan092

Untitled

Dec 20th, 2021
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. int TRIAC = 6;
  2. int speed_val=0;
  3. void setup()
  4. {
  5. Serial.begin(9600);
  6. pinMode(A0,INPUT);
  7. pinMode(TRIAC, OUTPUT);
  8. attachInterrupt(digitalPinToInterrupt(3), zero_crossing, CHANGE);
  9. }
  10. void zero_crossing()
  11. {
  12. //Serial.println(".");
  13. int chop_time = (200*speed_val);
  14. delayMicroseconds(chop_time);
  15. digitalWrite(TRIAC, HIGH);
  16. delayMicroseconds(10);
  17. digitalWrite(TRIAC, LOW);
  18. }
  19. void loop()
  20. {
  21. int pot=analogRead(A0);
  22. if(pot>650){pot=660;}
  23. int data1 = map(pot, 0, 660,30,10);
  24. speed_val=data1;
  25. Serial.println(data1);
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement