Advertisement
Guest User

Untitled

a guest
Jul 6th, 2015
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1.  
  2. #define VERMELHO 9
  3. #define AMARELO 10
  4. #define VERDE 11
  5.  
  6. int numeros[10][7] =
  7. {
  8. // A B C D E F G
  9. { 1, 1, 1, 1, 1, 1, 0 }, // Num 0
  10. { 0, 1, 1, 0, 0, 0, 0 }, // Num 1
  11. { 1, 1, 0, 1, 1, 0, 1 }, // Num 2
  12. { 1, 1, 1, 1, 0, 0, 1 }, // Num 3
  13. { 0, 1, 1, 0, 0, 1, 1 }, // Num 4
  14. { 1, 0, 1, 1, 0, 1, 1 }, // Num 5
  15. { 1, 0, 1, 1, 1, 1, 1 }, // Num 6
  16. { 1, 1, 1, 0, 0, 0, 0 }, // Num 7
  17. { 1, 1, 1, 1, 1, 1, 1 }, // Num 8
  18. { 1, 1, 1, 0, 0, 1, 1 }, // Num 9
  19. };
  20.  
  21. int portas[7] = {
  22. // A B C D E F G
  23. 6,5,2,3,4,7,8
  24. };
  25.  
  26. void exibir_numero(int num)
  27. {
  28. if (num < 10) {
  29. int i = 0;
  30.  
  31. while (i < 7) {
  32. int porta = portas[i];
  33. if (numeros[num][i] == 1) {
  34. // Acender o LED
  35. digitalWrite(porta, HIGH);
  36. } else {
  37. // Apagar o LED
  38. digitalWrite(porta, LOW);
  39. }
  40. i++;
  41. }
  42. }
  43. }
  44.  
  45. void setup() {
  46. int i = 2;
  47. while (i < 9) {
  48. pinMode(i, OUTPUT);
  49. digitalWrite(i, HIGH);
  50. i++;
  51. }
  52. Serial.begin(9600);
  53. }
  54.  
  55. void loop() {
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement