SHARE
TWEET

Untitled

a guest Aug 19th, 2019 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top