Advertisement
Guest User

Untitled

a guest
Aug 19th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. #include <TimerOne.h>
  2.  
  3. int buttonState = 0;
  4. int lastButtonState = 0;
  5. int period = 1000;
  6. int sig_out = 9;
  7. int sig_out2 = 10;
  8. int button =2;
  9.  
  10. void setup() {
  11.  
  12. pinMode(button,INPUT_PULLUP);
  13. pinMode(sig_out, OUTPUT);
  14. //pinMode(sig_out2, OUTPUT);
  15. Timer1.initialize(1000);
  16. Timer1.pwm(sig_out,507,period);
  17. Serial.print(period);
  18. //Timer1.pwm(sig_out2,456,900);
  19. }
  20. void loop(){
  21. buttonState = digitalRead(button);
  22. if (buttonState != lastButtonState){
  23. lastButtonState = buttonState;
  24. if (buttonState == 1){
  25. period -= 10;
  26. Timer1.setPeriod(period);
  27. }
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement