Advertisement
Guest User

Untitled

a guest
Apr 29th, 2016
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. int a=0;
  2. int b=0;
  3. int c=0;
  4. int d=0;
  5. int numero=0;
  6. int disp[][7]={
  7. {1, 1, 1, 1, 1, 1, 0},
  8. {0, 1, 1, 0, 0, 0, 0},
  9. {1, 1, 0, 1, 1, 0, 1},
  10. {1, 1, 1, 1, 0, 0, 1},
  11. {0, 1, 1, 0, 0, 1, 1},
  12. {1, 0, 1, 1, 0, 1, 1},
  13. {1, 0, 1, 1, 1, 1, 1},
  14. {1, 1, 1, 0, 0, 0, 0},
  15. {1, 1, 1, 1, 1, 1, 1},
  16. {1, 1, 1, 1, 0, 1, 1},
  17. {1, 1, 1, 0, 1, 1, 1},
  18. {0, 0, 1, 1, 1, 1, 1},
  19. {1, 0, 0, 1, 1, 1, 0},
  20. {0, 1, 1, 1, 1, 0, 1},
  21. {1, 0, 0, 1, 1, 1, 1},
  22. {1, 0, 0, 0, 1, 1, 1}
  23. };
  24. void setup() {
  25. pinMode(2, INPUT_PULLUP);
  26. pinMode(3, INPUT_PULLUP);
  27. pinMode(4, INPUT_PULLUP);
  28. pinMode(5, INPUT_PULLUP);
  29. pinMode(13, OUTPUT);
  30. pinMode(12, OUTPUT);
  31. pinMode(11, OUTPUT);
  32. pinMode(10, OUTPUT);
  33. pinMode(9, OUTPUT);
  34. pinMode(8, OUTPUT);
  35. pinMode(7, OUTPUT);
  36. }
  37.  
  38. void loop() {
  39. if(digitalRead(2)==LOW){
  40. a=1;
  41. }else{
  42. a=0;
  43. }
  44. if(digitalRead(3)==LOW){
  45. b=1;
  46. }else{
  47. b=0;
  48. }
  49. if(digitalRead(4)==LOW){
  50. c=1;
  51. }else{
  52. c=0;
  53. }
  54. if(digitalRead(5)==LOW){
  55. d=1;
  56. }else{
  57. d=0;
  58. }
  59.  
  60. numero = a*1 + b*2 + c*4 + d*8;
  61. for(int i=0; i<7; i++){
  62. digitalWrite(13-i, disp[numero][i]);
  63. }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement