I purchase one of SureElectronic's 40Segment Bar graph on ebay this fall and i've finally got some time to fool around with it yet it's getting the better of me. They have very good documentation on it, I can't find a link to the documents on the site I can't find the product either, but trust me it does exist
They provide sample code to get it to work with a Pic but I don't use pic I use arduino so that is no help to me. here is the Pic code they provide.
#include <pic.h>
__CONFIG(UNPROTECT&MCLRDIS&WDTDIS); //Configure Word
#define Fuc_key GP3
#define DIMM GP2
#define CLK GP1
#define DATA GP0
unsigned char time;
unsigned char position;
unsigned char key_pressed,last_key_pressed;
void delay_20ms(void)
{
unsigned char i, j, k;
for(i = 0; i < 20; i++)
{
for(j = 0; j < 200; j++)
k--;
}
}
void SEG_Shift1(void)
{
unsigned char i;
position++;
if(position>40)position=0;
for(i = 0;i < 40; i++)
{
if(i==position) DATA=0;
else DATA = 1;
CLK = 0;
CLK = 1;
}
}
void SEG_Shift2(void)
{
unsigned char i;
position++;
for(i = 0;i < position; i++)
{
DATA = 1;
CLK = 0;
CLK = 1;
}
for(i = 0;i < (40-position); i++)
{
DATA = 0;
CLK = 0;
CLK = 1;
}
if(position>40)position=0;
}
void SEG_Shift3(void)
{
unsigned char i;
position++;
for(i = 0;i < (40-position); i++)
{
DATA = 1;
CLK = 0;
CLK = 1;
}
for(i = 0;i < position; i++)
{
DATA = 0;
CLK = 0;
CLK = 1;
}
if(position>40)position=0;
}
void change(void)
{
key_pressed=Fuc_key;
if((key_pressed==0)&(last_key_pressed==1))
{
if(key_pressed==0)
{
time++;
if(time>3)time=1;
}
}
last_key_pressed=key_pressed;
}
void main(void)
{
OSCCAL=0;
TRIS = 0b11111000;
OPTION=0b10011111;
while(1)
{
change();
if(time==1)SEG_Shift1();
if(time==2)SEG_Shift2();
if(time==3)SEG_Shift3();
delay_20ms();
}
}
Anyone want to give a try at porting this for the arduino?