Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Stepper.h>
- //leds
- int led = 2;
- int ledState = LOW;
- //botões
- //botão 1
- int buttonPin = 12; // botão no pino 12 ação 1
- int estadoBotao = 0;
- //botão 2
- int buttonPin2 = 11; // botão no pino 11 ação 2
- int estadoBotao2 = 0;
- //motor de passo
- int passos = 30;
- int tarefa = 0;
- void setup() {
- pinMode(led, OUTPUT);
- pinMode(buttonPin, INPUT);
- pinMode(buttonPin2, INPUT);
- }
- void loop() {
- unsigned long Tempo = millis();// inicia a contagem
- estadoBotao = digitalRead(buttonPin);
- estadoBotao2 = digitalRead(buttonPin2);
- if ((estadoBotao == 1 && tarefa == 0) {
- myStepper.step(passos);
- ledState = HIGH;
- if (Tempo - millis() >= 3000) {// acende led por 3 segundo
- Tempo = millis();// reinicia a contagem
- ledState = LOW;
- }
- tarefa = 1;// devine como ação 1 executada
- }
- if ((estadoBotao2 == 1 && tarefa == 1) {
- myStepper.step(passos);
- if (Tempo - millis() >= 1000) {// pisca o led a cada 1 segundo
- Tempo = millis();// reinicia a contagem
- ledState = HIGH;
- } else {
- ledState = LOW;
- }
- tarefa = 1;// devine como ação 2 executada
- }
- digitalWrite(led, ledState); // liga o led
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement