Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- This is used for testing AF coil by sweeping PWM values and thereby changing duty cycle of the PWM output.
- 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
- Ayush Sagar
- 15 Jul 2014
- */
- int coilPin = 11;
- int value = 0;
- int increment = 1;
- void setup() {
- // Set coil pin to output
- pinMode(coilPin, OUTPUT);
- }
- // the loop routine runs over and over again forever:
- void loop() {
- // value reset condition
- if (255 - value < 1) value = 0;
- // set PWM:
- analogWrite(coilPin, value);
- // increment value
- value += increment;
- // delay
- delay(39);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement