Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
- Committer:
- yu10078999
- Date:
- 2016-09-04
- Revision:
- 1:ce89d84cafaa
- Parent:
- 0:05ed3adc34ad
- Child:
- 2:1b8ea01637ad
File content as of revision 1:ce89d84cafaa:
#include "mbed.h"
DigitalOut datapin(D8);
DigitalOut latchpin(D9);
DigitalOut clockpin(D10);
DigitalOut xx(D11);
DigitalOut zz(D12);
DigitalOut yy(D13);
const int state[10][7]= {
{ 0, 1, 1, 1, 1, 1, 1}, // 0
{ 0, 0, 0, 0, 1, 1, 0}, // 1
{ 1, 0, 1, 1, 0, 1, 1}, // 2
{ 1, 0, 0, 1, 1, 1, 1}, // 3
{ 1, 1, 0, 0, 1, 1, 0}, // 4
{ 1, 1, 0, 1, 1, 0, 1}, // 5
{ 1, 1, 1, 1, 1, 0, 0}, // 6
{ 0, 0, 0, 0, 1, 1, 1}, // 7
{ 1, 1, 1, 1, 1, 1, 1}, // 8
{ 1, 1, 0, 0, 1, 1, 1} // 9
};
void seg1(int num)
{
xx=1;
zz=1;
yy=1;
latchpin=0;
for(int i=0;i<=7;i++)
{
datapin=state[num][i];
clockpin=1;
clockpin=0;
}
latchpin=1;
zz=0;
}
void seg2(int num)
{
xx=1;
zz=1;
yy=1;
latchpin=0;
for(int i=0;i<=7;i++)
{
datapin=state[num][i];
clockpin=1;
clockpin=0;
}
latchpin=1;
xx=0;
}
void seg3(int num)
{
xx=1;
zz=1;
yy=1;
latchpin=0;
for(int i=0;i<=7;i++)
{
datapin=state[num][i];
clockpin=1;
clockpin=0;
}
latchpin=1;
yy=0;
}
int main()
{
int round=0,round2=0,round3=0,r=0;
while(1)
{
seg1(round);
r++;
if (r>=10)
{
round++;
r=0;
}
wait_ms(5);
seg2(round2);
wait_ms(5);
seg3(round3);
wait_ms(5);
if(round == 10)
{
round=0;round2++;
if(round2 == 10)
{
round2=0;round3++;
if(round3 == 10)
{
round3=0;
}
}
}
}
}