0% found this document useful (0 votes)
60 views

Arduino Seven Seg

This Arduino program uses a 7-segment display module to create a countdown timer. It includes an Arduino Uno, breadboard, 7-segment display module, and jumper wires. The program code initializes the 7-segment display, sets the number of digits and digit pins, and controls the brightness. It then checks the serial port for a new number value, parses it, and displays it on the 7-segment display while also printing it to the serial monitor.

Uploaded by

ian jhefer
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
60 views

Arduino Seven Seg

This Arduino program uses a 7-segment display module to create a countdown timer. It includes an Arduino Uno, breadboard, 7-segment display module, and jumper wires. The program code initializes the 7-segment display, sets the number of digits and digit pins, and controls the brightness. It then checks the serial port for a new number value, parses it, and displays it on the 7-segment display while also printing it to the serial monitor.

Uploaded by

ian jhefer
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Title: Countdown Timer

Introduction :

This program will use a 7-segment display to make a countdown program

Materials :

- Arduino Uno
- breadboard
- 1 x 7-segment display module
- jumper wires

Program Code:

/* Arduino Tutorial - 7 Segment


One 7 segment is one digit, from 0 to 9.
Dev: Vasilakis Michalis // Date: 25/7/2015 // www.ardumotive.com */

//Library
#include "SevenSeg.h"

//Defines the segments A-G: SevenSeg(A, B, C, D, E, F, G);


SevenSeg disp (10,9,8,7,6,11,12);
//Number of 7 segments
const int numOfDigits =1;
//CC(or CA) pins of segment
int digitPins [numOfDigits]={4};

//Variables
int number=0; //Default number
int flag;

void setup() {

Serial.begin(9600);
//Defines the number of digits to be "numOfDigits" and the digit pins to be the
elements of the array "digitPins"
disp.setDigitPins ( numOfDigits , digitPins );
//Only for common cathode 7segments
disp.setCommonCathode();
//Control brightness (values 0-100);
disp.setDutyCycle(50);

void loop()
{
//Check if incoming data is available:
if (Serial.available() > 0)
{
// If it is, we'll use parseInt() to pull out only numbers:
number = Serial.parseInt();
flag=0;
}

//Valid range is from 1 to 9


if (number>=1 && number<=9){
//Print number to 7 segment display
disp.writeDigit(number);

//Print message to serial monito only once


if (flag==0){
//Print number to serial monitor
Serial.print("Number on 7 segment display:");
Serial.println(number);
flag=1;
}
}
}

You might also like