Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <LiquidCrystal.h>
- LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
- volatile int count=0;
- long debounce_time=0;
- long debounce=300;
- double freq=1;
- static const int LED_PIN=13;
- static const int digital_pin=2;
- bool previousButtonState=HIGH;
- void interrupt_handle(){
- if(millis()-debounce_time>debounce){
- freq=freq+freq*1/10;
- delay(20);
- Serial.print(freq);
- delay(20);
- Serial.println();
- }
- debounce_time=0;
- }
- void led_miganie(int freq){
- digitalWrite(LED_PIN,HIGH);
- delay(60/freq);
- digitalWrite(LED_PIN,LOW);
- delay(60/freq);
- }
- void setup() {
- // put your setup code here, to run once:
- Serial.begin(9600);
- lcd.begin(16, 2);
- lcd.print("waiting...");
- pinMode(digital_pin,INPUT);
- pinMode(LED_PIN,OUTPUT);
- //attachInterrupt(digitalPinToInterrupt(digital_pin), interrupt_handle, FALLING);
- }
- void loop() {
- // put your main code here, to run repeatedly:
- bool currentButtonState=digitalRead(digital_pin);
- if((currentButtonState==LOW)&&(previousButtonState==HIGH)){
- interrupt_handle();
- }
- if(Serial.available()>0){
- freq=1;
- Serial.read();
- Serial.print(freq);
- delay(20);
- Serial.println();
- }
- previousButtonState=currentButtonState;
- led_miganie(freq);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement