בעל תצוגה של 4 ספרות, Seven Segments. כאשר הבקרה על הספרות מתבצעת ע"י רכיב max7219.
רכיב זה יכול להציג עד 8 ספרות שונות או לחילופין 64 לדים שונים.התקשורת עם הרכיב פשוטה למדי, ומתבצעת בפרוטוקול SPI.
מעבר לכך,יש 3 כפתורים,בעלי לחיצה קצרה או ארוכה,
1 קידום תוצאה-לחיצה קצרה
2 הורדת תוצאה- לחיצה ארוכה
3 כפתור מעבר בין תצוגת תוצאה לתצוגת שעון - לחיצה קצרה, ריסט-לחיצה ארוכה.
הלדים עצמם הם "5mm Red LED Lamp Light Bulb Ultra Bright Mcd" .. לדעתי לא מספיק טובים, ובעל עוצמת תאורה לא מספקת, בעלי פיזור אור לא מספק ובקיצור, לא נראה מספיק טוב ביום...לשעות בין הערביים או ערב, בסדר גמור.
לכן , אני ממליץ על לדים 12 וולט שבאים ברצועות. יש לי כאלה מאחורי השלטים "HOME AWAY" והם נראים יותר טוב.
הבעיה היא שהם חזקים יותר, ואני לא בטוח אם הרכיב max7219 יכול לספק מתח\זרם שלהם...צריך לבדוק

בכל מקרה את הבעיה הנ"ל בטוח ניתן לפתור ע"י טרניסטור שיפקד על כל segment ואחד שיפקד על כל "GND" של ספרה.
אם יש לכם כל שאלה בנושא,או שברצונכם לבנות משהו דומה תרגישו חופשי לשאול ולהגיב.
מספר תמונות של הבניה וסרטון של התוצאה הסופית מובאות בהמשך להנאתכם.
http://www.youtube.com/watch?v=SnNwakxXJ6E
קוד התוכנית
קוד: בחירת הכל
#include <Time.h>
#include <TimeAlarms.h>
#include "LedControl.h"
LedControl lc=LedControl(6,7,5,1);
const int delaycr=80;
const int delaycr2=200;
const int button_reset_Pin=8;
const int button_HOME_Pin=10;
const int button_AWAY_Pin=9;
int num_sec_H;
int num_sec_L;
int num_min_H;
int num_min_L;
int num_hr_H;
int num_hr_L;
int HOME,AWAY;
int reset_state=0,home_state=0,away_state=0;
int i=0,j=0,toggle=0,k=0;
int home_h,home_l,away_h,away_l;
void setup()
{
pinMode(button_reset_Pin, INPUT);
pinMode(button_HOME_Pin, INPUT);
pinMode(button_AWAY_Pin, INPUT);
lc.shutdown(0,false);
/* Set the brightness to a medium values */
lc.setIntensity(0,14);
/* and clear the display */
lc.clearDisplay(0);
Serial.begin(9600);
setTime(0,0,0,0,0,0); // set time to Saturday 8:29:00am Jan 1 2011
// Alarm.alarmRepeat(10,0,7, Pin_8_ON_Alarm); // Turn pin 8 HIGH
// Alarm.alarmRepeat(10,0,19,Pin_8_OFF_Alarm ); //Turn pin 8 LOW
// create the alarms
//Alarm.alarmRepeat(10,0,7, MorningAlarm); // 8:30am every day
//Alarm.alarmRepeat(17,45,0,EveningAlarm); // 5:45pm every day
//Alarm.alarmRepeat(dowSaturday,8,30,30,WeeklyAlarm); // 8:30:30 every Saturday
// Alarm.timerRepeat(15, Repeats); // timer for every 15 seconds
//Alarm.timerOnce(10, OnceOnly); // called once after 10 seconds
//digitalClockDisplay();
}
void loop(){
// Read button push, short push = 1, long push = 2
//********************************************************************************************
reset_state=0;
home_state=0;
away_state=0;
// read buttons loop. k=8,9,10 => reset,away,home
for (k=8;k<=10;k++){
// read reset button
if ( digitalRead(k) == HIGH) {
j=0;
do
{
delay (10);
if (digitalRead(k) == LOW or j > 300){
goto endofpush;
}
j++; // j is the number of how long is the push.
} while (1);
endofpush:
switch (k) {
case 8:
if (j <= 300)
reset_state=1; // short push
if( j > 300)
reset_state=2; // long push push
break;
case 10:
if (j <= 300)
away_state=1; // short push
if( j > 300)
away_state=2; // long push push
break;
case 9:
if (j <= 300)
home_state=1; // short push
if( j > 300)
home_state=2; // long push push
break;
}
}
}
//******** finish reading the button states
//** show funney 7 segment tricks
if (reset_state == 2 and home_state==2 and away_state==2)
crazyseven();
if (reset_state == 2) { // reset the game, home = away = time = 0
HOME=0;
AWAY=0;
setTime(0,0,0,0,0,0); // set time to Saturday 8:29:00am Jan 1 2011
}
if (reset_state == 1) { // display SCORE OR TIME
toggle=!toggle;
}
if (home_state == 1) { // home ++
HOME++;
}
if (home_state == 2) { // home --
HOME--;
if (HOME <=0 )
HOME=0;
}
if (away_state == 1) { // away ++
AWAY++;
}
if (away_state == 2) { // away --
AWAY--;
if (AWAY <=0 )
AWAY=0;
}
//*************************************************************************************
// updating score and time var's
home_h=HOME / 10 ;
home_l=HOME % 10 ;
away_h=AWAY / 10 ;
away_l=AWAY % 10 ;
time_t t = now(); // store the current time in time variable t
num_sec_H=second(t) / 10;
num_sec_L=second(t) % 10;
num_min_H=minute(t) / 10;
num_min_L=minute(t) % 10;
num_hr_H=hour(t) / 10;
num_hr_L=hour(t) % 10;
// show score OR time
if (toggle==0){
if (HOME <= 9)
{ lc.setDigit(0,3,home_h,false); lc.setDigit(0,2,home_l,false); }
else
{ lc.setDigit(0,3,home_h,false); lc.setDigit(0,2,home_l,false); }
if (AWAY <= 9)
{ lc.setDigit(0,3,away_h,false); lc.setDigit(0,2,away_l,false); }
else
{ lc.setDigit(0,3,away_h,false); lc.setDigit(0,2,away_l,false); }
/*
Serial.println();
Serial.print("home : ");Serial.print(home_h); Serial.print(home_l); Serial.print(" - ");Serial.print("away ");Serial.print(away_h);Serial.print(away_l);
Serial.println();
*/
}
else{
lc.setDigit(0,3,num_min_H,false);
lc.setDigit(0,2,num_min_L,false);
lc.setDigit(0,1,num_sec_H,false);
lc.setDigit(0,0,num_sec_L,false);
Serial.println();
Serial.print("time : ");Serial.print(num_min_H); Serial.print(num_min_L); Serial.print(':');Serial.print(num_sec_H);Serial.print(num_sec_L);
Serial.println();
}
if (away_state == 2 or home_state == 2 )
delay(2000);
}//end of void main
void crazyseven(){
Serial.println();
Serial.println("crazy7");
Serial.println();
for(int i=1; i<=10 ; i++){
lc.clearDisplay(0);
//setDigit(int addr, int digit, byte value, boolean dp);
lc.setDigit(0,0,8,false);
lc.setDigit(0,1,8,false);
lc.setDigit(0,2,8,false);
lc.setDigit(0,3,8,false);
delay(250);
lc.clearDisplay(0);
delay(250);
}
lc.clearDisplay(0);
for(int j=0;j<=3;j++){
for(int k=1;k<=5;k++){
for ( int i=1;i<=6;i++){
//setLed(int addr, int row, int column, boolean state);
lc.setLed(0, j, i, true);
delay(delaycr);
lc.setLed(0, j, i, false);
}
}
}
lc.clearDisplay(0);
for(int j=3;j>=0;j--){
for(int k=1;k<=5;k++){
for ( int i=6;i>=1;i--){
//setLed(int addr, int row, int column, boolean state);
lc.setLed(0, j, i, true);
delay(delaycr);
lc.setLed(0, j, i, false);
}
}
}
for(int j=0;j<=3;j++){
for(int k=1;k<=5;k++){
lc.setLed(0, j, 1, true);
delay(delaycr);
lc.setLed(0, j, 1, false);
lc.setLed(0, j, 2, true);
delay(delaycr);
lc.setLed(0, j, 2, false);
lc.setLed(0, j, 7, true);
delay(delaycr);
lc.setLed(0, j, 7, false);
lc.setLed(0, j, 5, true);
delay(delaycr);
lc.setLed(0, j, 5, false);
lc.setLed(0, j, 4, true);
delay(delaycr);
lc.setLed(0, j, 4, false);
lc.setLed(0, j, 3, true);
delay(delaycr);
lc.setLed(0, j, 3, false);
lc.setLed(0, j, 7, true);
delay(delaycr);
lc.setLed(0, j, 7, false);
lc.setLed(0, j, 6, true);
delay(delaycr);
lc.setLed(0, j, 6, false);
}
}
//*******8
lc.setDigit(0,0,8,false);
lc.setDigit(0,1,8,false);
lc.setDigit(0,2,8,false);
lc.setDigit(0,3,8,false);
for(int j=0;j<=3;j++){
for(int k=1;k<=5;k++){
lc.setLed(0, j, 1, false);
delay(delaycr2);
lc.setLed(0, j, 1, true);
lc.setLed(0, j, 2, false);
delay(delaycr2);
lc.setLed(0, j, 2, true);
lc.setLed(0, j, 7, false);
delay(delaycr2);
lc.setLed(0, j, 7, true);
lc.setLed(0, j, 5, false);
delay(delaycr2);
lc.setLed(0, j, 5, true);
lc.setLed(0, j, 4, false);
delay(delaycr2);
lc.setLed(0, j, 4, true);
lc.setLed(0, j, 3, false);
delay(delaycr2);
lc.setLed(0, j, 3, true);
lc.setLed(0, j, 7, false);
delay(delaycr2);
lc.setLed(0, j, 7, true);
lc.setLed(0, j, 6, false);
delay(delaycr2);
lc.setLed(0, j, 6, true);
}
}
//*******88
lc.clearDisplay(0);
delay(250);
for(int k=1;k<=10;k++){
for(int j=0;j<=3;j++)
lc.setLed(0, j, 1, true);
delay(delaycr);
for(int j=0;j<=3;j++)
lc.setLed(0, j, 1, false);
for(int j=0;j<=3;j++)
lc.setLed(0, j, 2, true);
delay(delaycr);
for(int j=0;j<=3;j++)
lc.setLed(0, j, 2, false);
for(int j=0;j<=3;j++)
lc.setLed(0, j, 7, true);
delay(delaycr);
for(int j=0;j<=3;j++)
lc.setLed(0, j, 7, false);
for(int j=0;j<=3;j++)
lc.setLed(0, j, 5, true);
delay(delaycr);
for(int j=0;j<=3;j++)
lc.setLed(0, j, 5, false);
for(int j=0;j<=3;j++)
lc.setLed(0, j, 4, true);
delay(delaycr);
for(int j=0;j<=3;j++)
lc.setLed(0, j, 4, false);
for(int j=0;j<=3;j++)
lc.setLed(0, j, 3, true);
delay(delaycr);
for(int j=0;j<=3;j++)
lc.setLed(0, j, 3, false);
for(int j=0;j<=3;j++)
lc.setLed(0, j, 7, true);
delay(delaycr);
for(int j=0;j<=3;j++)
lc.setLed(0, j, 7, false);
for(int j=0;j<=3;j++)
lc.setLed(0, j, 6, true);
delay(delaycr);
for(int j=0;j<=3;j++)
lc.setLed(0, j, 6, false);
}
for(int j=0;j<=3;j++){
lc.setLed(0, j, 2, true);
lc.setLed(0, j, 3, true);
delay(delaycr2);
lc.setLed(0, j, 1, true);
lc.setLed(0, j, 7, true);
lc.setLed(0, j, 4, true);
delay(delaycr2);
lc.setLed(0, j, 6, true);
lc.setLed(0, j, 5, true);
delay(delaycr2);
}
delay(delaycr2);
for(int j=3;j>=0;j--){
lc.setLed(0, j, 6, false);
lc.setLed(0, j, 5, false);
delay(delaycr2);
lc.setLed(0, j, 1, false);
lc.setLed(0, j, 7, false);
lc.setLed(0, j, 4, false);
delay(delaycr2);
lc.setLed(0, j, 2, false);
lc.setLed(0, j, 3, false);
delay(delaycr2);
}
for (k=1;k<=2;k++){
for(int j=0;j<=3;j++)
lc.setLed(0, j, 1, true);
delay(delaycr2);
for(int j=0;j<=3;j++){
lc.setLed(0, j, 2, true);
lc.setLed(0, j, 6, true);
}
delay(delaycr2);
for(int j=0;j<=3;j++)
lc.setLed(0, j, 7, true);
delay(delaycr2);
for(int j=0;j<=3;j++){
lc.setLed(0, j, 3, true);
lc.setLed(0, j, 5, true);
}
delay(delaycr2);
for(int j=0;j<=3;j++)
lc.setLed(0, j, 4, true);
delay(delaycr2);
delay(delaycr2);
for(int j=0;j<=3;j++)
lc.setLed(0, j, 1, false);
delay(delaycr2);
for(int j=0;j<=3;j++){
lc.setLed(0, j, 2, false);
lc.setLed(0, j, 6, false);
}
delay(delaycr2);
for(int j=0;j<=3;j++)
lc.setLed(0, j, 7, false);
delay(delaycr2);
for(int j=0;j<=3;j++){
lc.setLed(0, j, 3, false);
lc.setLed(0, j, 5, false);
}
delay(delaycr2);
for(int j=0;j<=3;j++)
lc.setLed(0, j, 4, false);
delay(delaycr2);
}
for(int i=1; i<=10 ; i++){
lc.clearDisplay(0);
//setDigit(int addr, int digit, byte value, boolean dp);
lc.setDigit(0,0,8,false);
lc.setDigit(0,1,8,false);
lc.setDigit(0,2,8,false);
lc.setDigit(0,3,8,false);
delay(250);
lc.clearDisplay(0);
delay(250);
}
lc.clearDisplay(0);
}
// functions to be called when an alarm triggers:
void Pin_8_ON_Alarm(){
digitalWrite(8,HIGH);
}
void Pin_8_OFF_Alarm(){
digitalWrite(8,LOW);
}
void MorningAlarm(){
Serial.println("Alarm: - turn lights off");
}
void EveningAlarm(){
Serial.println("Alarm: - turn lights on");
}
void WeeklyAlarm(){
Serial.println("Alarm: - its Monday Morning");
}
void ExplicitAlarm(){
Serial.println("Alarm: - this triggers only at the given date and time");
}
void Repeats(){
Serial.println("15 second timer");
}
void OnceOnly(){
Serial.println("This timer only triggers once");
}
void digitalClockDisplay()
{
// digital clock display of the time
Serial.print(hour());
printDigits(minute());
printDigits(second());
Serial.println();
}
void printDigits(int digits)
{
Serial.print(":");
if(digits < 10)
Serial.print('0');
Serial.print(digits);
}