2 Sparkfun’s 7-Segment Red 6.5? Display and Arduino

A few weeks ago I posted about connecting Sparkfun’s 7-Segment 6.5″ Display’s to Arduino. In that post I only showed how to hook up 1 digit. In this post I will show how to hook up 2, but it scales to however many you want to add. Much of the same applies from my previous post but here are new diagrams and code.

 
int dataPin = 11;
int clockPin = 12;
int latchPin = 8;
 
int len = 10;
 
//holders for infromation you're going to pass to shifting function
byte dataRED;
byte dataArrayRED[10];
 
byte off = 0x00;
byte decimalpoint = 0x80;
 
 
 
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
 
}
 
void loop() {
 
int count = 100;
int val = 10; //this is for how many digits
 
 
 
for( int i = 0; i<count; i++ )
{
  digitalWrite(latchPin, 0);
 
 
   int digit2 = i % val;
  int digit1 = ( i - digit2 ) / val;
 
    shiftOut(dataPin, clockPin, dataArrayRED[ digit2 ]);
    shiftOut(dataPin, clockPin, dataArrayRED[ digit1 ]);
 
  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<<i) ) 
    {
	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);
}

I also have a video uploaded on viddler

Now that I have this up and running I just have to do something useful with it. And I have to find a better way to solder the digits, because there are wires everywhere.

Continue reading » · Rating: · Written on: 06-19-09 · 13 Comments »

Automatic Builds Presentation Reference Links

Here are some reference links for my presentation.

Installing Subversion on OSX

ANT

Flash ANT Tasks

Flex ANT Tasks docs

Hudson

sample Flash build.xml

<?xml version="1.0"?>
<project default="all" basedir=".">
 
	<condition property="flash" value="">
		<os family="mac" />
	</condition>
 
	<condition property="flash" value="C:\Program Files\Adobe\Adobe Flash CS3\Flash.exe">
		<os family="windows" />
	</condition>
 
	<property name="dev.dir" value="/Library/WebServer/Documents/sceneit" />
	<property name="fla.dir" value="${basedir}/src" />
	<property name="swf.output.dir" value="${basedir}/bin" />
 
	<taskdef resource="FlashAntTasks.properties" classpath="FlashAntTasks.jar"/>
 
	<target name="all" depends="version, compileflash, uploadtodev" />
 
	<property name="src" location="Classes/com/fuelindustries" description="Fuel library path" />
	<target name="version">
		<exec executable="svnversion" output="temp.txt">
			<arg line="-n" />
		</exec>
 
		<replaceregexp file="temp.txt" flags="gs" match="([0-9]+)(:)(.*)" replace="\1" />
		<loadfile srcFile="temp.txt" property="revision" />
 
		<replaceregexp file="${src}/BuildNumber.as" flags="gi" match='BUILD_NUMBER : String = "[0-9A-Za-z]*"' replace='BUILD_NUMBER : String = "${revision}"' />
		<delete file="temp.txt" />
	</target>
 
	<target name="compileflash">
		<flashcommand flashapp="${flash}">
			<movie export="true" source="${fla.dir}/prototype.fla" output="${swf.output.dir}/prototype.swf" />
		</flashcommand>
	</target>
 
	<target name="uploadtodev">
		 <copy todir="${dev.dir}" overwrite="true" >
   			 <fileset dir="${swf.output.dir}" />
  		 </copy>
	</target>
 
</project>
 
<!--
 
Helpful tasks
 
Copying a whole directory	
<copy todir="pathtonewdir" overwrite="true" >
	<fileset dir="dirtocopy"/>
</copy>
 
Getting the current date stamp
<property name="now" value="${DSTAMP}-${TSTAMP}" />
 
Creating ASDocs
<exec executable="asdoc" failonerror="true">
    <arg line="-source-path Classes -doc-sources Classes/" />
</exec>
 
Updating SVN
<exec executable="svn">
	<arg line="update trunk -r HEAD" />
</exec>
 
 
<movie> Task properties
closeDocAfterComplete = false;
closeFlashAfterComplete = false;
publish = false;
testMovie = false;
saveAndCompact = false;
-->

Sample BuildNumber.as

package com.fuelindustries 
{
	public class BuildNumber 
	{
		public static const BUILD_NUMBER : String = "7M";
	}
}
Continue reading » · Rating: · Written on: 06-09-09 · 1 Comment »