Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <TimerOne.h>
- int buttonState = 0;
- int lastButtonState = 0;
- int period = 1000;
- int sig_out = 9;
- int sig_out2 = 10;
- int button =2;
- void setup() {
- pinMode(button,INPUT_PULLUP);
- pinMode(sig_out, OUTPUT);
- //pinMode(sig_out2, OUTPUT);
- Timer1.initialize(1000);
- Timer1.pwm(sig_out,507,period);
- Serial.print(period);
- //Timer1.pwm(sig_out2,456,900);
- }
- void loop(){
- buttonState = digitalRead(button);
- if (buttonState != lastButtonState){
- lastButtonState = buttonState;
- if (buttonState == 1){
- period -= 10;
- Timer1.setPeriod(period);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement