Devices & Components
Arduino Uno Rev3
Breadboard (generic)
Male/Male Jumper Wires
Seven-Segment Display
Project description
Code
Here is the code for this basic project.
c_cpp
This is the code I used.
1//SSD is Seven-Segment Display 2 3void setup() 4{ 5 for (int i = 0; i <= 13; i++) 6 pinMode(i, OUTPUT); //Set all pins from 0 to 13 as OUTPUT 7} 8//The line below is the array containing all the binary numbers for the digits on a SSD from 0 to 9 9const int number[11] = {0b1000000, 0b1111001, 0b0100100, 0b0110000, 0b0011001, 0b0010010, 0b0000010, 0b1111000, 0b0000000, 0b0010000}; 10 11void loop() 12{ 13 for (int tens = 0; tens < 10; tens++) 14 15 { 16 display_tens(tens); 17 } 18} 19 20void display_tens(const int tens) 21{ 22 int pin1, a, ones; 23 //pin1 is just used to deal with pins of the 1st SSD which desplays the tens digit 24 25 for (pin1 = 0, a = 0; pin1 < 7; pin1++, a++) 26 { 27 digitalWrite(pin1, bitRead(number[tens], a)); 28 } 29 for (ones = 0; ones < 10; ones++) 30 { 31 display_ones(ones); 32 delay(300); 33 //I have given a delay of 300 milliseconds. You can put your own Time!! 34 } 35} 36 37void display_ones(const int x) 38{ int pin2, b; 39//pin2 is just used to deal with pins of the 2nd SSD which desplays the ones digit 40 41 for (pin2 = 7, b = 0; pin2 <= 13; pin2++, b++) 42 { 43 digitalWrite(pin2, bitRead(number[x], b)); 44 45 } 46 47} 48
Here is the code for this basic project.
c_cpp
This is the code I used.
1//SSD is Seven-Segment Display 2 3void setup() 4{ 5 for (int 6 i = 0; i <= 13; i++) 7 pinMode(i, OUTPUT); //Set all pins from 0 to 13 as OUTPUT 8} 9//The 10 line below is the array containing all the binary numbers for the digits on a SSD 11 from 0 to 9 12const int number[11] = {0b1000000, 0b1111001, 0b0100100, 0b0110000, 13 0b0011001, 0b0010010, 0b0000010, 0b1111000, 0b0000000, 0b0010000}; 14 15void loop() 16{ 17 18 for (int tens = 0; tens < 10; tens++) 19 20 { 21 display_tens(tens); 22 23 } 24} 25 26void display_tens(const int tens) 27{ 28 int pin1, a, ones; 29 30 //pin1 is just used to deal with pins of the 1st SSD which desplays the tens digit 31 32 33 for (pin1 = 0, a = 0; pin1 < 7; pin1++, a++) 34 { 35 digitalWrite(pin1, 36 bitRead(number[tens], a)); 37 } 38 for (ones = 0; ones < 10; ones++) 39 { 40 41 display_ones(ones); 42 delay(300); 43 //I have given a delay of 300 44 milliseconds. You can put your own Time!! 45 } 46} 47 48void display_ones(const 49 int x) 50{ int pin2, b; 51//pin2 is just used to deal with pins of 52 the 2nd SSD which desplays the ones digit 53 54 for (pin2 = 7, b = 0; pin2 <= 55 13; pin2++, b++) 56 { 57 digitalWrite(pin2, bitRead(number[x], b)); 58 59 60 } 61 62} 63
Downloadable files
The connections
Here is how I connected the jumper wires on the board.The resistors are not shown here.
The connections

Comments
Only logged in users can leave comments