Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const String programa = "shutdown";
- char buffer[128];
- const int chave = 2;
- const int rele = 5;
- int cont = 2;
- //------------------------------------------
- void setup()
- {
- Serial.begin(9600);
- Serial.flush();
- pinMode (chave, INPUT_PULLUP);
- pinMode (5, OUTPUT );
- delay (10000);
- Serial.println("Inicializado...");
- digitalWrite (5, HIGH);
- }
- //------------------------------------
- void loop()
- {
- if (digitalRead(2) == 0)
- { // }
- delay(30); // Delay para debouncing
- if (digitalRead(2) == 0) // Se o botao continua pressionado
- {
- cont++;
- delay (2000);
- }
- } // }
- if (cont == 3)
- {
- cont = 1;
- }
- if (cont == 1)
- {
- digitalWrite (5, HIGH);
- delay (500);
- }
- else if (cont == 2)
- {
- if (!digitalRead(chave))
- {
- delay(200);
- if (!digitalRead(chave))
- {
- sprintf (buffer, "#2cmd:%s#3", programa.c_str());
- Serial.println(buffer);
- delay (30000);
- digitalWrite (5, LOW);
- delay (500);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement