Em có code mà ko vẽ được lưu đồ khối, ai có thể hd em làm với:
#include <AT89X51.H>
#include<stdio.h>
#include<math.h>
#define bat 1
#define tat 0
#define den1 P2
//=================
sbit led1=P0^0;
sbit led2=P0^1;
sbit led3=P0^2;
sbit led4=P0^3;
sbit x1=P1^0;
sbit v1=P1^1;
sbit d1=P1^2;
sbit d2=P1^5;
sbit v2=P1^4;
sbit x2=P1^3;
sbit START = P3^4;//Khoi dong che do giao dong
sbit STOP = P3^5;//nhan chuyen sang che do ban dem
//=================
char m[10]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x9 0};
int num1,donvi1,chuc1;
int num2,donvi2,chuc2;
//============delay=====
void delay(int ms)
{
int a,b;
for(a=0;a<ms;a++)
for(b=0;b<125;b++)
{
}
}
//=========hien thi=============
void ht1(void)
{
int c;
for(c=0;c<20;c++)
{
chuc1=num1/10;
donvi1=num1%10;
den1=m[chuc1];
led3=bat;
delay(10);
led3=tat;
den1=m[donvi1];
led4=bat;
delay(10);
led4=tat;
chuc2=num2/10;
donvi2=num2%10;
den1=m[chuc2];
led1=bat;
delay(10);
led1=tat;
den1=m[donvi2];
led2=bat;
delay(10);
led2=tat;
}
}
//=========ham chinh==========
void main(void)
{
while(1)
{ P1=0x00;
if((START ==0)&&(STOP==1))
{
num1=30;
num2=35;
do
{
P3=0x00;
x1=bat;
d2=bat;
ht1();
num1--;
num2--;
}
while(num1!=0);
num1=num2=5;
do
{
P3=0x00;
v1=bat;
x1=tat;
ht1();
num1--;
num2--;
}
while(num1!=0);
num1=35;
num2=30;
do
{
P3=0x00;
v1=tat;
d1=bat;
d2=tat;
x2=bat;
ht1();
num1--;
num2--;
}
while(num2!=0);
num1=num2=5;
do
{
P3=0x00;
x2=tat;
v2=bat;
ht1();
num1--;
num2--;
}
while(num1!=0);
}
if((START==1)&&(STOP==0))
{
x1= tat;
v1= bat;
d1= tat;
d2= tat;
v2= bat;
x2= tat;
P0=0x00 ;
}
}
}
#include <AT89X51.H>
#include<stdio.h>
#include<math.h>
#define bat 1
#define tat 0
#define den1 P2
//=================
sbit led1=P0^0;
sbit led2=P0^1;
sbit led3=P0^2;
sbit led4=P0^3;
sbit x1=P1^0;
sbit v1=P1^1;
sbit d1=P1^2;
sbit d2=P1^5;
sbit v2=P1^4;
sbit x2=P1^3;
sbit START = P3^4;//Khoi dong che do giao dong
sbit STOP = P3^5;//nhan chuyen sang che do ban dem
//=================
char m[10]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x9 0};
int num1,donvi1,chuc1;
int num2,donvi2,chuc2;
//============delay=====
void delay(int ms)
{
int a,b;
for(a=0;a<ms;a++)
for(b=0;b<125;b++)
{
}
}
//=========hien thi=============
void ht1(void)
{
int c;
for(c=0;c<20;c++)
{
chuc1=num1/10;
donvi1=num1%10;
den1=m[chuc1];
led3=bat;
delay(10);
led3=tat;
den1=m[donvi1];
led4=bat;
delay(10);
led4=tat;
chuc2=num2/10;
donvi2=num2%10;
den1=m[chuc2];
led1=bat;
delay(10);
led1=tat;
den1=m[donvi2];
led2=bat;
delay(10);
led2=tat;
}
}
//=========ham chinh==========
void main(void)
{
while(1)
{ P1=0x00;
if((START ==0)&&(STOP==1))
{
num1=30;
num2=35;
do
{
P3=0x00;
x1=bat;
d2=bat;
ht1();
num1--;
num2--;
}
while(num1!=0);
num1=num2=5;
do
{
P3=0x00;
v1=bat;
x1=tat;
ht1();
num1--;
num2--;
}
while(num1!=0);
num1=35;
num2=30;
do
{
P3=0x00;
v1=tat;
d1=bat;
d2=tat;
x2=bat;
ht1();
num1--;
num2--;
}
while(num2!=0);
num1=num2=5;
do
{
P3=0x00;
x2=tat;
v2=bat;
ht1();
num1--;
num2--;
}
while(num1!=0);
}
if((START==1)&&(STOP==0))
{
x1= tat;
v1= bat;
d1= tat;
d2= tat;
v2= bat;
x2= tat;
P0=0x00 ;
}
}
}
Comment