overvolt

Arduino 16: Multiplexer

Sep 8th, 2018
1,322
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. int s0 = 8;
  2. int s1 = 9;
  3. int s2 = 10;
  4. int s3 = 11;
  5. int sig = 0;
  6.  
  7. int multiplexer[16][4] = { {0,0,0,0}, //canale 0
  8. {0,0,0,1}, //canale 1
  9. {0,0,1,0}, //canale 2
  10. {0,0,1,1}, //canale 3
  11. {0,1,0,0}, //canale 4
  12. {0,1,0,1}, //canale 5
  13. {0,1,1,0}, //canale 6
  14. {0,1,1,1}, //canale 7
  15. {1,0,0,0}, //canale 8
  16. {1,0,0,1}, //canale 9
  17. {1,0,1,0}, //canale 10
  18. {1,0,1,1}, //canale 11
  19. {1,1,0,0}, //canale 12
  20. {1,1,0,1}, //canale 13
  21. {1,1,1,0}, //canale 14
  22. {1,1,1,1} //canale 14
  23. };
  24.  
  25.  
  26. void setup() {
  27. // put your setup code here, to run once:
  28. pinMode(s0,OUTPUT);
  29. pinMode(s1,OUTPUT);
  30. pinMode(s2,OUTPUT);
  31. pinMode(s3,OUTPUT);
  32. Serial.begin(9600);
  33. }
  34.  
  35. void loop() {
  36. // put your main code here, to run repeatedly:
  37. interfaccia(2);
  38. Serial.read();
  39. interfaccia(6);
  40. Serial.read();
  41. }
  42.  
  43. void interfaccia(int canale) {
  44. int controllore[] = {s3,s2,s1,s0};
  45. for(int i=0;i<4;i++)
  46. digitalWrite(controllore[i],multiplexer[canale][i]);
  47. }
Advertisement
Add Comment
Please, Sign In to add comment