08.11.2017 Views

arduino_básico_Michael_McRoberts

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Capítulo 7 ■ Displays de LED<br />

155<br />

Listagem 7.1 – Código para o projeto 19<br />

// Projeto 19<br />

#include <br />

int latchPin = 8; // Pino conectado ao pino 12 do 74HC595 (Latch)<br />

int clockPin = 12; // Pino conectado ao pino 11 do 74HC595 (Clock)<br />

int dataPin = 11; // Pino conectado ao pino 14 do 74HC595 (Data)<br />

byte led[8]; // array de bytes com 8 elementos para armazenar o sprite<br />

void setup() {<br />

pinMode(latchPin, OUTPUT); // define os 3 pinos digitais como saída<br />

pinMode(clockPin, OUTPUT);<br />

pinMode(dataPin, OUTPUT);<br />

led[0] = B11111111; // insere a representação binária da imagem<br />

led[1] = B10000001; // no array<br />

led[2] = B10111101;<br />

led[3] = B10100101;<br />

led[4] = B10100101;<br />

led[5] = B10111101;<br />

led[6] = B10000001;<br />

led[7] = B11111111;<br />

// define um timer com duração de 10000 microssegundos (1/100 de um segundo)<br />

Timer1.initialize(10000);<br />

// anexa a função screenUpdate ao timer de interrupção<br />

Timer1.attachInterrupt(screenUpdate);<br />

}<br />

void loop() {<br />

for (int i=0; i> 1; // deslocamento para a direita<br />

}<br />

}

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!