Go Down

Topic: LED Dot Matrix Basic Animation - Beginning Arduino: Project 19 (Read 1 time) previous topic - next topic


Mar 07, 2013, 01:31 am Last Edit: Mar 07, 2013, 01:33 am by marcosricardoss Reason: 1
Hello everybody,

I'm trying to make the project 19 of the book Beginning Arduino by Michael McRoberts, but I have a hard time not find solution anywhere.

Here are the problems:

The project code 19 of the book is this:


#include <TimerOne.h>

int latchPin = 8; //Pin connected to Pin 12 of 74HC595 (Latch)
int clockPin = 12; //Pin connected to Pin 11 of 74HC595 (Clock)
int dataPin = 11; //Pin connected to Pin 14 of 74HC595 (Data)

byte led[8];  // 8 element unsigned integer array to store the sprite

void setup() {
       pinMode(latchPin, OUTPUT);  // set the 3 digital pins to outputs
       pinMode(clockPin, OUTPUT);
       pinMode(dataPin, OUTPUT);
       led[0] = B11111111;  // enter the binary representation of the image
       led[1] = B10000001;  // into the array
       led[2] = B10111101;
       led[3] = B10100101;
       led[4] = B10100101;
       led[5] = B10111101;
       led[6] = B10000001;
       led[7] = B11111111;
       // set a timer of length 10000 microseconds (1/100th of a second)
       // attach the screenUpdate function to the interrupt timer

void loop() {
       for (int i=0; i<8; i++) {
               led= ~led; // invert each row of the binary image

void screenUpdate() { // function to display image
       byte row = B10000000; // row 1
       for (byte k = 0; k < 9; k++) {
               digitalWrite(latchPin, LOW); // open latch ready to receive data
       shiftIt(~led[k] ); // shift out the LED array (inverted)
       shiftIt(row ); // shift out row binary number

       // Close the latch, sending the data in the registers out to the matrix
       digitalWrite(latchPin, HIGH);    
       row = row >> 1; // bitshift left

void shiftIt(byte dataOut) {    // Shift out 8 bits LSB first, on rising edge of clock

       boolean pinState;
       digitalWrite(dataPin, LOW); //clear shift register read for sending data

       for (int i=0; i<8; i++)  {    // for each bit in dataOut send out a bit
               digitalWrite(clockPin, LOW); //set clockPin to LOW prior to sending bit

               // if the value of DataOut and (logical AND) a bitmask
               // are true, set pinState to 1 (HIGH)
               if ( dataOut & (1<<i) ) {
                              pinState = HIGH;
               else {
                       pinState = LOW;
               //sets dataPin to HIGH or LOW depending on pinState
               digitalWrite(dataPin, pinState);
               digitalWrite(clockPin, HIGH); //send bit out on rising edge of clock
               digitalWrite(dataPin, LOW);
digitalWrite(clockPin, LOW); //stop shifting

I typed the code and did not work at first. I thought the problem was the circuit that use shift register, did the countless tests and realize that I was correct. One of the test was to count binary column and row and it worked correctly.

When I added 'delay (1)'  on line 44, the project works almost perfectly (some blinking leds that was not to be fishing).

I'm new to the Arduino world ... and not know where to go right now. In another project related to LED Dot Matrix had already partially solved this problem adding a 'delay (1)'.

anyone have any suggestions for my question?

Sorry for my English (by google translate  :D)

thank you

See the same project but with Matrix Common Cathode: http://mindovermaterial.wordpress.com/2012/07/17/beginning-arduino-project-19-led-dot-matrix-basic-animation/


Personally, I found the error! my mistake  XD

In the project I had used this circuit: http://www.arduino.cc/en/Tutorial/ShiftOut

But in the book the circuit with shift register was altered slightly. In the circuit of the book was not bound in capicitor Pinor clock. When I took worked normal.

Already people complaining about the same problem on the internet! I believe it is the same error.

Thank you all anyway  ;)


Already knew this post, and as I said above ... my problem is in the circuit, already fixed it!

but thanks

Go Up