Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Feito por Rafael Mugnol
- #include "Servo.h"
- Servo s;
- const int chave = 12;
- int aux;
- boolean pos;
- int i = 40;
- int f = 142;
- int commands[][300] =
- {
- {f, 300}, // seq0
- {100, 1000, f, 300}, // seq1
- {f, 2000}, // seq2
- {84, 50, 80, 50, 84, 50, 80, 50, 84, 50, 80, 50, 84, 50, 80, 50, 80, 50, 80, 50, 84, 50, 80, 50, 84, 50, 80, 50, 84, 50, 80, 50, 84, 50, 80, 50, 84, 50, 80, 50, 84, 50, 80, 50, 84, 50, 80, 50, 84, 50, 80, 50, 84, 50, i, 1000, f, 300}, // seq 3
- {120, 1000, i, 2000, f, 300}, // seq4
- {70, 50, 60, 50, 70, 50, 60, 50, 70, 50, 60, 50, 70, 50, 60, 50, 70, 50, 60, 50, 70, 50, 60, 50, 70, 50, 60, 50, 70, 50, 60, 50, 70, 50, 60, 50, 70, 50, 60, 50, 70, 50, 60, 50, 70, 50, 60, 50, 70, 50, 75, 1000, f, 300}, // seq5
- {}, // seq6 - populado externamente
- {f, 300}, // seq7 - igual ao seq0
- {70, 50, 60, 50, 70, 50, 60, 50, 70, 50, 60, 50, 70, 50, 60, 50, 70, 50, 60, 50, 70, 50, 60, 50, 70, 50, 60, 50, 70, 50, 60, 50, 70, 50, 60, 50, 70, 50, 60, 50, 70, 50, 60, 50, 70, 50, 60, 50, 70, 50, i, 1000, 60, 50, 70, 50, 60, 50, 70, 50, 60, 50, 70, 50, 60, 50, 70, 50, 60, 50, 70, 50, 60, 50, 70, 50, 60, 50, 70, 50, f, 300}, // seq8
- {100, 1000, f, 300}, // seq9 - igual ao seq1
- {120, 200, 110, 400, 110, 400, 110, 400, 50, 500, 90, 100, 85, 100, 90, 100, 85, 100, 90, 100, 85, 100, 90, 100, 85, 100, f, 300}, // seq10
- {5000, f, 300}
- };
- void popularSeq6()
- {
- int ley = 0; int index = 0;
- for (ley = i; ley < f; ley++){
- commands[6][index++] = ley;
- commands[6][index++] = 20;
- }
- }
- void setup(){
- popularSeq6();
- s.attach(8);
- aux = 0;
- pinMode(13, OUTPUT);
- pinMode(chave,INPUT);
- if (digitalRead(chave) == HIGH)
- {
- pos = false;
- }
- else
- {
- pos = true;
- }
- }
- void processar(int seq[])
- {
- for(int i = 0; i < 300; i++)
- {
- if (seq[i] == 0) break;
- if (i % 2 == 0)
- s.write(seq[i]);
- else
- delay(seq[i]);
- }
- }
- void loop()
- {
- if(pos == false || true)
- {
- delay(10);
- if (digitalRead(chave) == HIGH)
- {
- s.write(i);
- }
- else
- {
- delay(500);
- processar(commands[aux]);
- aux++;
- if(aux>11) aux=0;
- }
- }
- else
- {
- delay(10);
- if (digitalRead(chave) == HIGH)
- {
- s.write(i);
- }
- else
- {
- s.write(f);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement