Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define BTN_LED 6
- int req;
- int bblink;
- int bled;
- unsigned long timer;
- int tb;
- bool block;
- bool re;
- void ledbtn_mode(int sd) {
- switch (sd) {
- case 1:
- if(bblink != 1) {
- digitalWrite(BTN_LED, HIGH);
- bblink = 1;
- }
- break;
- case 5:
- if(bblink != 5) {
- block = false;
- tb = 0;
- timer = millis();
- bblink = 5;
- }
- break;
- }
- }
- void setup() {
- Serial.begin(115200);
- pinMode(BTN_LED, OUTPUT);
- }
- void loop() {
- if(Serial.available() > 0) {
- req = Serial.parseInt();
- }
- if(req == 10){
- ledbtn_mode(1);
- } else if(req == 15) {
- ledbtn_mode(5);
- }
- if(bblink == 5) {
- if(tb < 6 && (millis() - timer) >= 500) {
- if(digitalRead(BTN_LED) == HIGH) {
- bled = LOW;
- } else {
- bled = HIGH;
- }
- digitalWrite(BTN_LED, bled);
- tb++;
- timer = millis();
- } else if(tb >= 6 && block == false) {
- Serial.println("<320>");
- if(digitalRead(BTN_LED) == LOW) {
- digitalWrite(BTN_LED, HIGH);
- }
- block = true;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement