Advertisement
tbatista

controle laminadora Nascimento

Nov 18th, 2016
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.20 KB | None | 0 0
  1.  
  2. #include <Stepper.h>
  3. //leds
  4. int led = 2;
  5. int ledState = LOW;
  6.  
  7. //botões
  8. //botão 1
  9. int buttonPin = 12; // botão no pino 12 ação 1
  10. int estadoBotao = 0;
  11.  
  12. //botão 2
  13. int buttonPin2 = 11; // botão no pino 11 ação 2
  14. int estadoBotao2 = 0;
  15.  
  16. //motor de passo
  17. int passos = 30;
  18. int tarefa = 0;
  19.  
  20.  
  21.  
  22. void setup() {
  23.   pinMode(led, OUTPUT);
  24.   pinMode(buttonPin, INPUT);
  25.   pinMode(buttonPin2, INPUT);
  26. }
  27.  
  28. void loop() {
  29.   unsigned long Tempo = millis();// inicia a contagem
  30.  
  31.   estadoBotao = digitalRead(buttonPin);
  32.   estadoBotao2 = digitalRead(buttonPin2);
  33.  
  34.   if ((estadoBotao == 1 && tarefa == 0) {
  35.   myStepper.step(passos);
  36.     ledState = HIGH;
  37.  
  38.     if (Tempo - millis() >= 3000) {// acende led por 3 segundo
  39.       Tempo = millis();// reinicia a contagem
  40.       ledState = LOW;
  41.     }
  42.     tarefa = 1;// devine como ação 1 executada
  43.   }
  44.   if ((estadoBotao2 == 1 && tarefa == 1) {
  45.   myStepper.step(passos);
  46.  
  47.     if (Tempo - millis() >= 1000) {// pisca o led a cada 1 segundo
  48.       Tempo = millis();// reinicia a contagem
  49.       ledState = HIGH;
  50.     } else {
  51.       ledState = LOW;
  52.     }
  53.     tarefa = 1;// devine como ação 2 executada
  54.   }
  55.   digitalWrite(led, ledState); // liga o led
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement