Advertisement
RuiViana

Sequencial sem botão

Nov 7th, 2015
280
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. // Testa LED sequencial Rui
  2. // Seguencia LEDs usando o CI 74HC595
  3.  
  4. int const clock = 2; // Conectar ao pino 11 dos 74HC595
  5. int const latch = 4; // Conectar ao pino 12 dos 74HC595
  6. int const data = 3; // Conectar ao pino 14 dos 74HC595
  7. boolean Level; // Nivel de Data
  8. // ********************************************************************
  9. void setup() {
  10. pinMode(clock,OUTPUT); // Port D2 saída
  11. pinMode(latch,OUTPUT); // Port D4 saída
  12. pinMode(data,OUTPUT); // Port D3 saída
  13. }
  14. // ********************************************************************
  15. void loop() {
  16. Level = !Level; // inverta o nivel de Data
  17. delay (500);
  18.  
  19. for (unsigned int i = 0; i<8; i++) // Faça 8 vezes
  20. {
  21. digitalWrite(data,Level); // Data bit ON acende 1o. LED
  22. digitalWrite(latch,LOW); // transfere dados dos regs para os latchs e saídas
  23. digitalWrite(clock,HIGH); // Liga clock para entra dado
  24. digitalWrite(clock,LOW); // Desiga clock
  25. digitalWrite(latch,HIGH); // Desatica transferencia
  26.  
  27. if(Level == 1)
  28.  
  29. delay(500); // Tempo de LED aceso
  30. }
  31. } // End loop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement