Advertisement
ayush3504

Untitled

Jul 14th, 2014
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.67 KB | None | 0 0
  1. /*
  2. This is used for testing AF coil by sweeping PWM values and thereby changing duty cycle of the PWM output.
  3. The PWM frequency on most pins is ~490 Hz. However, it's ~980 Hz for pins 5 and 6 on the Uno, and for pins 3 and 11 on the Leonardo
  4.  
  5. Ayush Sagar
  6. 15 Jul 2014
  7. */
  8.  
  9. int coilPin = 11;  
  10. int value = 0;  
  11. int increment = 1;
  12.  
  13. void setup() {
  14.   // Set coil pin to output
  15.   pinMode(coilPin, OUTPUT);
  16. }
  17.  
  18. // the loop routine runs over and over again forever:
  19. void loop() {
  20.   // value reset condition
  21.   if (255 - value < 1) value = 0;
  22.  
  23.   // set PWM:
  24.   analogWrite(coilPin, value);
  25.  
  26.   // increment value
  27.   value += increment;
  28.  
  29.   // delay
  30.   delay(39);
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement