Hi all
I have posted about my project before.
I am trying to convert my old scoreboard by using an Arduino and some Sparkfun TPIC6C596 large digit drivers to be controlled by buttons. I down loaded a sketch from Sparkfun for a single digit and a guy from sparkfun wrote some code for the buttons. I downloaded it to my Arduino and it worked fine. I have now got a sketch for a double digit and I have added some button code myself. Would someone please have a look at the code and advise me if it is ok. I know I will get back just download it and see what happens. But I did try, not with this code and the Arduino stopped working and I have had to buy a new one. I can daisy chain These TPIC6C596 drivers.
Eddie
If you killed the Arduino, something is wrong with your hardware (cabling). Fix this problem first, or you risk to burn the next Arduino as quickly as the first one.
I will do that if coding will not burn the Arduino out
Code can not burn out an Arduino. Only a hardware fault can do that.
We someone please take a look at my code and give me some sort of feed back.
You post it right I will look at it. Many people here use mobile devices and so an .ino file simply can not be downloaded and looked at.
Please read this:- How to use this forum
It will tell you the rules about posting code on this forum.
/*
Controlling large 7-segment displays
By: Nathan Seidle
SparkFun Electronics
Date: February 25th, 2015
License: This code is public domain but you buy me a beer if you use this and we meet someday (Beerware license).
This code demonstrates how to post two numbers to a 2-digit display usings two large digit driver boards.
Here's how to hook up the Arduino pins to the Large Digit Driver IN
Arduino pin 6 -> CLK (Green on the 6-pin cable)
5 -> LAT (Blue)
7 -> SER on the IN side (Yellow)
5V -> 5V (Orange)
Power Arduino with 12V and connect to Vin -> 12V (Red)
GND -> GND (Black)
There are two connectors on the Large Digit Driver. 'IN' is the input side that should be connected to
your microcontroller (the Arduino). 'OUT' is the output side that should be connected to the 'IN' of addtional
digits.
Each display will use about 150mA with all segments and decimal point on.
*/
//GPIO declarations
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
byte segmentClock = 6;
byte segmentLatch = 5;
byte segmentData = 7;
int upButton = 3;
int downButton = 2;
int score = 0;
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
void setup()
{
Serial.begin(9600);
Serial.println("Large Digit Driver Example");
pinMode(segmentClock, OUTPUT);
pinMode(segmentData, OUTPUT);
pinMode(segmentLatch, OUTPUT);
pinMode(upButton, INPUT_PULLUP);
pinMode(downButton, INPUT_PULLUP);
digitalWrite(segmentClock, LOW);
digitalWrite(segmentData, LOW);
digitalWrite(segmentLatch, LOW);
}
void loop()
{
postNumber(score,false); //show decimal
digitalWrite(segmentLatch, LOW);
digitalWrite(segmentLatch, HIGH);
if (! digitalRead(upButton)) {
score++;
score %=100;
delay (300);
Serial.println(score); //For debugging
}
if (! digitalRead(downButton)) {
score--;
if(score < 0) score +99;
delay (300);
Serial.println(score); //For debugging
}
}
//Takes a number and displays 2 numbers. Displays absolute value (no negatives)
void showNumber(float value)
{
int number = abs(value); //Remove negative signs and any decimals
//Serial.print("number: ");
//Serial.println(number);
for (byte x = 0 ; x < 2 ; x++)
{
int remainder = number % 10;
postNumber(remainder, false);
number /= 10;
}
//Latch the current segment data
digitalWrite(segmentLatch, LOW);
digitalWrite(segmentLatch, HIGH); //Register moves storage register on the rising edge of RCK
}
//Given a number, or '-', shifts it out to the display
void postNumber(byte number, boolean decimal)
{
// - A
// / / F/B
// - G
// / / E/C
// -. D/DP
#define a 1<<0
#define b 1<<6
#define c 1<<5
#define d 1<<4
#define e 1<<3
#define f 1<<1
#define g 1<<2
#define dp 1<<7
byte segments;
switch (number)
{
case 1: segments = b | c; break;
case 2: segments = a | b | d | e | g; break;
case 3: segments = a | b | c | d | g; break;
case 4: segments = f | g | b | c; break;
case 5: segments = a | f | g | c | d; break;
case 6: segments = a | f | g | e | c | d; break;
case 7: segments = a | b | c; break;
case 8: segments = a | b | c | d | e | f | g; break;
case 9: segments = a | b | c | d | f | g; break;
case 0: segments = a | b | c | d | e | f; break;
case ' ': segments = 0; break;
case 'c': segments = g | e | d; break;
case '-': segments = g; break;
}
if (decimal) segments |= dp;
//Clock these bits out to the drivers
for (byte x = 0 ; x < 8 ; x++)
{
digitalWrite(segmentClock, LOW);
digitalWrite(segmentData, segments & 1 << (7 - x));
digitalWrite(segmentClock, HIGH); //Data transfers to the register on the rising edge of SRCK
}
}
[code][code]
Hi all
I have posted about my project before.
I am trying to convert my old scoreboard by using an Arduino and some Sparkfun TPIC6C596 large digit drivers to be controlled by buttons. I down loaded a sketch from Sparkfun for a single digit and a guy from sparkfun wrote some code for the buttons. I downloaded it to my Arduino and it worked fine. I have now got a sketch for a double digit and I have added some button code myself. Would someone please have a look at the code and advise me if it is ok. I know I will get back just download it and see what happens. But I did try, not with this code and the Arduino stopped working and I have had to buy a new one. I can daisy chain These TPIC6C596 drivers.
Eddie