safwan092

Untitled

Jan 1st, 2022 (edited)
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. const int output_1 = 9;
  2. const int output_2 = 10;
  3. const int output_3 = 11;
  4. const int t = 2770;
  5. //t = 2777; // t*6 = 16662 uS ===> f = 1/(t*6) = 60.0168 = 60 Hz
  6. //t = 3310; // t*6 = 19860 uS ===> f = 1/(t*6) = 50.3524 = 50 Hz
  7. void setup()
  8. {
  9. pinMode(output_1, OUTPUT); // Phase 1
  10. pinMode(output_2, OUTPUT); // Phase 2
  11. pinMode(output_3, OUTPUT); // Phase 3
  12. }
  13. void loop()
  14. {
  15. delayMicroseconds(t);
  16. digitalWrite(output_1, LOW);
  17. delayMicroseconds(t);
  18. digitalWrite(output_2, HIGH);
  19. delayMicroseconds(t);
  20. digitalWrite(output_3, LOW);
  21. delayMicroseconds(t);
  22. digitalWrite(output_1, HIGH);
  23. delayMicroseconds(t);
  24. digitalWrite(output_2, LOW);
  25. delayMicroseconds(t);
  26. digitalWrite(output_3, HIGH);
  27. }
Add Comment
Please, Sign In to add comment