Advertisement
Terrificten

one Tesla custom interruptor code for arduino

May 19th, 2019
401
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. int outPin = 8; // digital pin 8
  2. int analogPin = 3;
  3. int raw;
  4. int duty;
  5. void setup()
  6. {
  7. pinMode(outPin, OUTPUT); // sets the digital pin as output
  8. }
  9.  
  10. void loop()
  11. {
  12. raw = analogRead (analogPin);
  13. if (raw > 1 and raw < 50) {
  14. duty = raw/3;
  15. digitalWrite(outPin, HIGH); // sets the pin on
  16. delayMicroseconds(duty);
  17. digitalWrite(outPin, LOW); // sets the pin off
  18. delayMicroseconds(0);
  19. }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement