I n this experiment,we wi l l  test digi ts 1 to 8,and auto scrol l  display on 7-seg LED.
The components used in this experiment are shown below:
The components are one 7-seg LED, 8 jumper wi res ,and one breadboard.
First step:Schematics:

## Step 3: A Rduino Code:

A rduino code:
//Configure the digi tal  I O pins that used to control  each segment of
the LED.
int a=7;
int b=6;
int c=5;
int d=11;
int e=10;
42 / 45
int f=8;
int g=9;
int dp=4;
//Display digi t 1
void digi tal_1(void)
{
unsigned char j ;
digi talWri te(c,LOW);
digi talWri te(b,LOW);
for(j=7;j<=11;j++)
digi talWri te(j ,HI GH);
digi talWri te(dp,HI GH);
}
//Display digi t 2
void digi tal_2(void)
{
unsigned char j ;
digi talWri te(b,LOW);
digi talWri te(a,LOW);
for(j=9;j<=11;j++)
digi talWri te(j ,LOW);
digi talWri te(dp,HI GH);
digi talWri te(c,HI GH);
digi talWri te(f,HI GH);
}
//Display digi t 3
void digi tal_3(void)
{
unsigned char j ;
digi talWri te(g,LOW);
43 / 45
digi talWri te(d,LOW);
for(j=5;j<=7;j++)
digi talWri te(j ,LOW);
digi talWri te(dp,HI GH);
digi talWri te(f,HI GH);
digi talWri te(e,HI GH);
}
//Digi t 4
void digi tal_4(void)
{
digi talWri te(c,LOW);
digi talWri te(b,LOW);
digi talWri te(f,LOW);
digi talWri te(g,LOW);
digi talWri te(dp,HI GH);
digi talWri te(a,HI GH);
digi talWri te(e,HI GH);
digi talWri te(d,HI GH);
}
//Display digi t 5
void digi tal_5(void)
{
unsigned char j ;
for(j=7;j<=9;j++)
digi talWri te(j ,LOW);
digi talWri te(c,LOW);
digi talWri te(d,LOW);
digi talWri te(dp,HI GH);
digi talWri te(b,HI GH);
digi talWri te(e,HI GH);
}
//Display digi t 6
void digi tal_6(void)
{
unsigned char j ;
for(j=7;j<=11;j++)
digi talWri te(j ,LOW);
digi talWri te(c,LOW);
digi talWri te(dp,HI GH);
digi talWri te(b,HI GH);
}
//Display digi t 7
void digi tal_7(void)
{
unsigned char j ;
for(j=5;j<=7;j++)
digi talWri te(j ,LOW);
digi talWri te(dp,HI GH);
for(j=8;j<=11;j++)
digi talWri te(j ,HI GH);
}
//Display digi t 8
void digi tal_8(void)
{
unsigned char j ;
for(j=5;j<=11;j++)
digi talWri te(j ,LOW);
digi talWri te(dp,HI GH);
}
void setup()
{
int i ;//define variable
for(i=4;i<=11;i++)
pinM ode(i ,OUTPUT);//set the mode of digi tal  pins 4-11 to OUTPUT
}
void loop()
{
whi le(1)
{
digi tal_1();//display digi t 1
delay(2000);//delay 2s
digi tal_2();
delay(2000);
digi tal_3();
delay(2000);
digi tal_4();
delay(2000);
digi tal_5();
delay(2000);
digi tal_6();
delay(2000);
digi tal_7();
delay(2000);
digi tal_8();
delay(2000);
}
}