SHARE
TWEET

Untitled

a guest Apr 25th, 2019 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. int A = 8;
  2. int B = 9;
  3. int C = 11;
  4. int D = 12;
  5. int E = 13;
  6. int F = 7;
  7. int G = 6;
  8. int DP = 10;
  9.  
  10. int SWI1 = 5;
  11. int SWI2 = 4;
  12.  
  13. // estados do switches
  14. int estadoSWI1 = 0;
  15. int estadoSWI2 = 0;
  16.  
  17. // cada nivel mostra sua Inicial no display de 7 segmentos.
  18. // baixo = b, normal = n, alto = A, descalibrado = d
  19.  
  20. void baixo() {        
  21.     digitalWrite(A,HIGH);
  22.     digitalWrite(B,HIGH);
  23.     digitalWrite(C,LOW);
  24.     digitalWrite(D,LOW);
  25.     digitalWrite(E,LOW);
  26.     digitalWrite(F,LOW);
  27.     digitalWrite(G,LOW);
  28.     digitalWrite(DP,HIGH);
  29. }
  30.  
  31. void normal() {            
  32.     digitalWrite(A,HIGH);
  33.     digitalWrite(B,HIGH);
  34.     digitalWrite(C,LOW);
  35.     digitalWrite(D,HIGH);
  36.     digitalWrite(E,LOW);
  37.     digitalWrite(F,HIGH);
  38.     digitalWrite(G,LOW);
  39.     digitalWrite(DP,HIGH);
  40. }
  41.  
  42. void alto() {
  43.     digitalWrite(A,LOW);
  44.     digitalWrite(B,LOW);
  45.     digitalWrite(C,LOW);
  46.     digitalWrite(D,HIGH);
  47.     digitalWrite(E,LOW);
  48.     digitalWrite(F,LOW);
  49.     digitalWrite(G,LOW);
  50.     digitalWrite(DP,HIGH);
  51. }
  52.  
  53. void descalibrado() {
  54.     digitalWrite(A,HIGH);
  55.     digitalWrite(B,LOW);
  56.     digitalWrite(C,LOW);
  57.     digitalWrite(D,LOW);
  58.     digitalWrite(E,LOW);
  59.     digitalWrite(F,HIGH);
  60.     digitalWrite(G,LOW);
  61.     digitalWrite(DP,HIGH);
  62. }
  63.  
  64. void setup()
  65. {
  66.     // ENTRADAS -> SWITCHES
  67.     pinMode(SWI1, INPUT);
  68.     pinMode(SWI2, INPUT);
  69.  
  70.     // SAIDAS -> DISPLAY DE 7 SEGMENTOS
  71.     pinMode(A, OUTPUT);
  72.     pinMode(B, OUTPUT);
  73.     pinMode(C, OUTPUT);
  74.     pinMode(D, OUTPUT);
  75.     pinMode(E, OUTPUT);
  76.     pinMode(F, OUTPUT);
  77.     pinMode(G, OUTPUT);
  78.     pinMode(DP, OUTPUT);
  79. }
  80.  
  81. void loop()
  82. {
  83.     estadoSWI1 = digitalRead(SWI1);
  84.     estadoSWI2 = digitalRead(SWI2);
  85.  
  86.     if (estadoSWI1 == LOW) {
  87.         if (estadoSWI2 == LOW) {  // state = 00
  88.             baixo();
  89.         } else {        // state = 01
  90.             normal();
  91.         }
  92.     } else {
  93.         if (estadoSWI2 == LOW) {
  94.             alto();     // state = 10
  95.         } else {
  96.             descalibrado(); // state = 11
  97.         }
  98.     }
  99. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top