SHARE
TWEET

Untitled

a guest Nov 15th, 2019 92 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #define LED 5
  2. #define BT 2
  3.  
  4. bool pressed = 0;
  5. bool flag = 0;
  6. bool led = 0;
  7. long int ml = 0;
  8. long int ml2 = 0;
  9. long int ispress = 0;
  10.  
  11. void ledd(){
  12.   if(millis() - ml2 > 500){
  13.     led = !led;
  14.     ml2 = millis();
  15.   }
  16. }
  17.  
  18. void setup() {
  19.   Serial.begin(9600);
  20.   pinMode(LED, OUTPUT);
  21. }
  22.  
  23. void loop() {
  24.   if(digitalRead(BT) == HIGH){
  25.     if(millis() - ml > 300){
  26.       ml = millis();
  27.       led = !led;
  28.       flag = 0;
  29.     }
  30.     if(millis() - ispress > 3000){
  31.       flag = 1;
  32.       ispress = millis();
  33.     }
  34.   }
  35.   if(flag) ledd();
  36.   else digitalWrite(LED, led);
  37.    
  38.  
  39. }
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
 
Top