Monday, June 3, 2013

2 Shift Registers on #Arduino

Shot a nice, blurry, bigfoot style video of my Arduino project using 2 shift registers. it isn't pretty, but you can see how it works, counting in binary.


I'll go through the actual build, as soon as I take the time to document it. Here's a picture of the build, that, I think, I've posted before.

Here's the Artwork
I finally took the time with Fritzing to do the artwork. Here is the circuit drawing and schematic.


int dataPin = 10;        //Define which pins will be used for the Shift Register control
int latchPin = 9;
int clockPin = 8;

int byte1 = 0;         //The counter for storing the byte #1 value
int byte2 = 0;         //The counter for storing the byte #2 value

void setup()
{
    pinMode(dataPin, OUTPUT);       //Configure each IO Pin
    pinMode(latchPin, OUTPUT);
    pinMode(clockPin, OUTPUT);
}

void loop()
{
    for (byte2 = 0; byte2 < 256; byte2++)               //Outer Loop
    {
        for (byte1 = 0; byte1 < 256; byte1++)            //Inner Loop
        {
            digitalWrite(latchPin, LOW);           //Pull latch LOW to start sending data
            shiftOut(dataPin, clockPin, MSBFIRST, byte1); //Send the data byte 1
            shiftOut(dataPin, clockPin, MSBFIRST, byte2); //Send the data byte 2
            digitalWrite(latchPin, HIGH);          //Pull latch HIGH to stop sending data
            delay(100);
        }
    }
}


Next Step
I;m going to add an interrupt connected to a pushbutton. I'm going to replace an LED in the center with a white one and place blue ones on either side. With this, I'll code a scan pattern that will work kinda like the game you see in arcades where you have to capture the light. When the button is pressed, the handler will stop the tracking and blink the captured LED for a set interval showing the LED that has been captured. Then we'll see where it goes from there.


No comments:

Post a Comment