Sparkfun’s 7-Segment Red 6.5″ Display and Arduino

A little while ago I purchased 10 of Sparkfun’s 7-segment red 6.5″ displays.

http://www.sparkfun.com/commerce/product_info.php?products_id=8530

I had been wanting to purchase them for quite some time but they had been out of stock. When I was finally notified that they had received more I instantly bought them, without really thinking what I was going to use them for. Once they arrived I quickly opened them up and saw that it was going to be a little bit more of a challenge then I originally thought it would be. And I also thought they would come with some fancy schematic that I could just follow, but they didn’t.

So the first step was just to try and get a segment to light up by just supplying power. The digits use a common anode, which means it has one lead connection and 7 ground connection for each segment. So I started running it through a 5v power supply with not luck. Then a 9v, still no luck. Finally 12v did the trick. After I soldered wires to all of the connection I was able to get all 7 segments to light up by just running the common anode to the power and each segment to a ground.

Ok so step one complete now to try and get it talking with Arduino. Now I wasn’t really sure how to go about doing this since each segment was connected to a ground. So I started digging around on the Arduino forums and found some similar posts on what I was trying to do. My conclusion was that I need to get a shift register to turn each segment on and off. I found some people who had some luck with this display and the Allegro 6278EAT. You can pick some up for $1.55 at Digi Key. There are lots of different LED drivers out there but the reason I chose this one was because I needed to supply 12v to my displays and it sounded like some of the others that people where recommending wouldn’t work.

So after a lot of experimenting and researching I was finally able to get the display to turn on and off with Arduino. This tutorial on the Arduino site was the most helpful. And I used the following Arduino sketch which I got from this post on the forums.

int dataPin = 11;
int clockPin = 12;
int latchPin = 10;
 
//holders for infromation you're going to pass to shifting function
byte dataRED;
 
byte dataArrayRED[11];
 
void setup() {
 
  //set pins to output because they are addressed in the main loop
  pinMode(latchPin, OUTPUT);
 
  //Arduino doesn't seem to have a way to write binary straight into the code
  //so these values are in HEX.  Decimal would have been fine, too.
  dataArrayRED[0] = 0x3F; //00111111 - 0
  dataArrayRED[1] = 0x06; //00000110 - 1
  dataArrayRED[2] = 0x5B; //01011011 - 2
  dataArrayRED[3] = 0x4F; //01001111 - 3
  dataArrayRED[4] = 0x66; //01100110 - 4
  dataArrayRED[5] = 0x6D; //01101101 - 5
  dataArrayRED[6] = 0x7D; //01111101 - 6
  dataArrayRED[7] = 0x07; //00000111 - 7
  dataArrayRED[8] = 0x7F; //01111111 - 8
  dataArrayRED[9] = 0x67; //01100111 - 9
  dataArrayRED[10] = 0x80; //decimal point
}
 
void loop() {
 
for (int i = 0; i<11; i++)
{
 
  dataRED = dataArrayRED[i];
 
    //ground latchPin and hold low for as long as you are transmitting
 
    digitalWrite(latchPin, 0);
    //move 'em out
 
    shiftOut(dataPin, clockPin, dataRED);
    //return the latch pin high to signal chip that it
    //no longer needs to listen for information
    digitalWrite(latchPin, 1);
    delay(300);
 
  delay(1000);
}
 
}
 
// the heart of the program
void shiftOut(int myDataPin, int myClockPin, byte myDataOut) {
  // This shifts 8 bits out MSB first,
  //on the rising edge of the clock,
  //clock idles low
 
  //internal function setup
  int i=0;
  int pinState;
  pinMode(myClockPin, OUTPUT);
  pinMode(myDataPin, OUTPUT);
 
  //clear everything out just in case to
  //prepare shift register for bit shifting
  digitalWrite(myDataPin, 0);
  digitalWrite(myClockPin, 0);
 
  //for each bit in the byte myDataOut…
  //NOTICE THAT WE ARE COUNTING DOWN in our for loop
  //This means that %00000001 or "1" will go through such
  //that it will be pin Q0 that lights.
  for (i=7; i>=0; i--)
  {
    digitalWrite(myClockPin, 0);
 
    //if the value passed to myDataOut and a bitmask result
    // true then... so if we are at i=6 and our value is
    // %11010100 it would the code compares it to %01000000
    // and proceeds to set pinState to 1.
    if( myDataOut & (1<
    {
	pinState= 1;
    }
    else
    {
	pinState= 0;
    }
 
    //Sets the pin to HIGH or LOW depending on pinState
    digitalWrite(myDataPin, pinState);
    //register shifts bits on upstroke of clock pin
    digitalWrite(myClockPin, 1);
    //zero the data pin after shift to prevent bleed through
    digitalWrite(myDataPin, 0);
  }
 
  //stop shifting
  digitalWrite(myClockPin, 0);
}

And here is a final diagram for connecting it to Arduino.

NOTE: the diagram shows a 15kohm resistor but it may not be bright enough. If you put a 2.2kohm resistor it will be much brighter

And here is a video of the display counting – http://www.viddler.com/explore/julian/videos/14/

I am working on getting more then one display working and will write a new post when I do

Continue reading » · Rating: · Written on: 05-30-09 · 4 Comments »

Installing Subversion locally on OSX

I have been working on getting Subversion installed on my Mac for the last couple of days in preparation for my talk at Flashbelt on Automatic Build Systems.

<Intermission>

As a quick plug. Flashbelt is one of the best Flash conferences in the world and I highly recommend going if you are in the area. I have some discount codes if you are planning on getting tickets within the next couple of weeks. Just leave a comment and I will send you one.

</Intermission>

Ok back on topic. There are a couple great posts out there that do a great job at explaining how to install Subversion on your Mac, but unfortunately they are a little out of date. So let’s do a little homework first.

Step 1.

Check what version of Subversion you are running. To do that open a Terminal window and type

svn help

This is assuming you already have the Subversion binaries installed. If you don’t you can download them from here.

In the first couple of lines in the output from that command it should say what version you are running.

Step 2.

Step 2 is just to follow all of the instructions on the followingThought Stream post. This takes you through the simple process of getting Subversion set up with Web DAV and working with localhost. If you have Subversion 1.4 installed then you are finished after these instructions. If you have a newer version then 1.4 come back for Step 3 after you are done.

Step 3.

Now we have to update the SVN Apache modules with the current version you have installed. If you kept the default path when installing Subversion navigate to /opt/subversion/lib/svn-apache.

In this directory there are 2 new .so files. All you need to do is overwrite the current modules in apache. To do that simply copy those 2 files to the following directory – /usr/libexec/apache

It may be a good idea to backup the original files but you should be ok if you didn’t. Once the new files are copied over you have successfully updated the SVN apache modules.

Step 4.

Now there is 1 last thing you will need to do in order to get everything working correctly. I am not even going to try and explain it because this post on Thought Spark explains it way better then I could ever do.

Step 5.

Everything should be all set now. All you have to do is restart apache and you should be able to navigate to your http://localhost/svn/games or whatever you named your repository and see the current revision.

To restart apache you can either un-check and check the Web Sharing checkbox in System Preferences > Sharing or you can use the following command

sudo apachectl restart
Continue reading » · Rating: · Written on: 05-18-09 · No Comments »