Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Testa LED sequencial Rui
- // Seguencia LEDs usando o CI 74HC595
- int const clock = 2; // Conectar ao pino 11 dos 74HC595
- int const latch = 4; // Conectar ao pino 12 dos 74HC595
- int const data = 3; // Conectar ao pino 14 dos 74HC595
- boolean Level; // Nivel de Data
- // ********************************************************************
- void setup() {
- pinMode(clock,OUTPUT); // Port D2 saída
- pinMode(latch,OUTPUT); // Port D4 saída
- pinMode(data,OUTPUT); // Port D3 saída
- }
- // ********************************************************************
- void loop() {
- Level = !Level; // inverta o nivel de Data
- delay (500);
- for (unsigned int i = 0; i<8; i++) // Faça 8 vezes
- {
- digitalWrite(data,Level); // Data bit ON acende 1o. LED
- digitalWrite(latch,LOW); // transfere dados dos regs para os latchs e saídas
- digitalWrite(clock,HIGH); // Liga clock para entra dado
- digitalWrite(clock,LOW); // Desiga clock
- digitalWrite(latch,HIGH); // Desatica transferencia
- if(Level == 1)
- delay(500); // Tempo de LED aceso
- }
- } // End loop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement