--> Project I - 11. Score Board using 7 Segment Display Based on Arduino | basic arduino tutorial

Thursday, August 24, 2017

Project I - 11. Score Board using 7 Segment Display Based on Arduino

| Thursday, August 24, 2017
Score Board using 7 Segment Display


This tool works as a futsal score counter, plus and minus score by pressing the button and the results are displayed on 7 segments.

Seven segment as display score of team 1 and team 2 which each team have 2 digit seven segment. As for the ride control and slide show using the UP and DOWN buttons. The RESET button is used to return the score to zero again. The score data is stored on EEPROM so that when the power is off the data is still stored.

Hardware Requirement
  • Arduino Uno Board
  • 4 Digit of 7-Segment with Common Anode
  • 5 Push Button
  • Power supply +5 Volt
  • Jumper


7-Segment | Source                     Push Button | Source

Block Diagram


Schematic


7-Segment CA Wiring | Source

Arduino - 7 Segment Wiring

Arduino - Buttons Wiring


Source Code/Sketch

#include <EEPROM.h>
long lastButton = 0;
long delayAntiBouncing = 50;
byte skor1, skor2;
byte seven_seg_digits[10][7] = { { 0,0,0,0,0,0,1 }, // = 0
{ 1,0,0,1,1,1,1 }, // = 1
{ 0,0,1,0,0,1,0 }, // = 2
{ 0,0,0,0,1,1,0 }, // = 3
{ 1,0,0,1,1,0,0 }, // = 4
{ 0,1,0,0,1,0,0 }, // = 5
{ 0,1,0,0,0,0,0 }, // = 6
{ 0,0,0,1,1,1,1 }, // = 7
{ 0,0,0,0,0,0,0 }, // = 8
{ 0,0,0,0,1,0,0 }, // = 9
};
void setup(){
for(char i=2; i<13; i++){
pinMode(i,OUTPUT);
}
pinMode(A0,INPUT);
pinMode(A1,INPUT);
pinMode(A2,INPUT);
pinMode(A3,INPUT);
pinMode(A4,INPUT);
digitalWrite(A0,HIGH);
digitalWrite(A1,HIGH);
digitalWrite(A2,HIGH);
digitalWrite(A3,HIGH);
digitalWrite(A4,HIGH);
skor1 = EEPROM.read(1);
skor2 = EEPROM.read(2);
if(skor1 == 255)skor1 = 0;
if(skor2 == 255)skor2 = 0;
}
void loop(){
tampilSkor();
tombol();
}
void tampilSkor(){
digitalWrite(10,LOW); digitalWrite(11,HIGH);
digitalWrite(12,HIGH); digitalWrite(13,HIGH);
sevenSegWrite(skor1 / 10);
delay(5);
digitalWrite(10,HIGH); digitalWrite(11,LOW);
digitalWrite(12,HIGH); digitalWrite(13,HIGH);
sevenSegWrite(skor1 % 10);
delay(5);
digitalWrite(10,HIGH); digitalWrite(11,HIGH);
digitalWrite(12,LOW); digitalWrite(13,HIGH);
sevenSegWrite(skor2 / 10);
delay(5);
digitalWrite(10,HIGH); digitalWrite(11,HIGH);
digitalWrite(12,HIGH); digitalWrite(13,LOW);
sevenSegWrite(skor2 % 10);
delay(5);
}
void sevenSegWrite(byte segment){
byte pin = 2;
for (byte segCount = 0; segCount < 7; ++segCount) {
digitalWrite(pin, seven_seg_digits[segment][segCount]);
++pin;
}
}
void tombol(){
//-----------------tombol UP 1
if(digitalRead(A0)==0){
if ((millis() - lastButton) > delayAntiBouncing){
if (skor1 < 99){
skor1++;
EEPROM.write(1, skor1);
}
}
lastButton = millis();
}
//---------------tombol DOWN 1
if(digitalRead(A1)==0){
if ((millis() - lastButton) > delayAntiBouncing){
if (skor1 > 0){
skor1--;
EEPROM.write(1, skor1);
}
}
lastButton = millis();
}
//-----------------tombol UP 2
if(digitalRead(A2)==0){
if ((millis() - lastButton) > delayAntiBouncing){
if (skor2 < 99){
skor2++;
EEPROM.write(2, skor2);
}
}
lastButton = millis();
}
//---------------tombol DOWN 2
if(digitalRead(A3)==0){
if ((millis() - lastButton) > delayAntiBouncing){
if (skor2 > 0){
skor2--;
EEPROM.write(2, skor2);
}
}
lastButton = millis();
}
//---------------tombol RESET
if(digitalRead(A4)==0){
if ((millis() - lastButton) > delayAntiBouncing){
skor1=0;
skor2=0;
EEPROM.write(1, skor1);
EEPROM.write(2, skor2);
}
lastButton = millis();
}
}

How it Works

1. Connect the Arduino with Peripherals needed.
2. Plug in the Power Source on the device.

3. Add some library if needed
4. Compile and upload the script program above to your arduino.
5. Display on the seven segment looks like this


6. Press UP1 button then score on team 1 will increase . So also for UP2 button.

7. Press DOWN1 button then score on team 1 will decrease . So also for DOWN2 button.
8. Press RESET button to return the score to zero all.



Video for Project I - 11. Score Board using 7 Segment Display Based on Arduino





Required file

Related Posts

No comments:

Post a Comment