Advertisement
RuiViana

RCB.ino

Jul 1st, 2021 (edited)
1,186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.24 KB | None | 0 0
  1. int xpto = 0;
  2. byte A = 1;
  3. byte B = 2;
  4. byte C = 3;
  5. byte D = 4;
  6. int valor = 0;
  7. //--------------------------------------------------------
  8. void setup()
  9. {
  10.   Serial.begin(115200);
  11. }
  12. //--------------------------------------------------------
  13. void loop()
  14. {
  15.   valor = 0x4321;
  16.   executa();
  17.  
  18.   valor = 0x3214;
  19.   executa();
  20.   Serial.println(" ");
  21. }
  22. //--------------------------------------------------------
  23. void executa()
  24. {
  25.   for (int i = 1; i < 5; i++)
  26.   {
  27.     xpto = 0x000F & valor;
  28.     valor = valor >> 4 ;
  29.  
  30.     switch (xpto)
  31.     {
  32.       case 1:
  33.         Serial.println(A);
  34.         digitalWrite(2, HIGH);
  35.         delay(1000);
  36.         digitalWrite(2, LOW);
  37.         delay(1000);
  38.         break;
  39.       case 2:
  40.         Serial.println(B);
  41.         digitalWrite(3, HIGH);
  42.         delay(1000);
  43.         digitalWrite(3, LOW);
  44.         delay(1000);
  45.         break;
  46.       case 3:
  47.         Serial.println(C);
  48.         digitalWrite(4, HIGH);
  49.         delay(1000);
  50.         digitalWrite(4, LOW);
  51.         delay(1000);
  52.         break;
  53.       case 4:
  54.         Serial.println(D);
  55.         digitalWrite(5, HIGH);
  56.         delay(1000);
  57.         digitalWrite(5, LOW);
  58.         delay(1000);
  59.         break;
  60.       default:
  61.         break;
  62.     }
  63.   }
  64. }
  65.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement