Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const byte BT[] = {13, 12, 11, 10};
- const unsigned long TEMPO[] = {1000, 2000, 3000, 4000};
- const String STATUS[] = {"FOME", "SONO", "IRRITADO", "DOENTE"};
- void setup () {
- for (byte i = 0; i < 4; i++) {
- pinMode(BT[i], OUTPUT);
- }
- Serial.begin (9600);
- }
- void loop () {
- unsigned long tatual = millis ();
- static unsigned long t0[] = {0, 0, 0, 0};
- static byte i = 0;
- if (i >= 4) i = 0;
- if (digitalRead(BT[i])) {
- Serial.println("NORMAL");
- t0[i] = tatual;
- } else if (tatual - t0[i] >= TEMPO[i]) {
- Serial.println(STATUS[i]);
- }
- i++;
- }
Advertisement
Add Comment
Please, Sign In to add comment