schematic diagram:
Assembly list:
assembly | ID | Value | Instruction |
STC15F104E | U1 | | 8051 series |
Capacity | C1 | 100nF | |
Resistance | R1,R2 | 220 | |
LED | D1,D2 | | |
buzzer | B1 | | |
Interface | J1,J2 | | J1 is application programming interface. J2 is power interface. |
Brief introduction:
The circuit uses an integrated STC15F 104E singlechip with inner oscillator and has a few peripheral components. It is easy to program by UART burning. The circuit can use simple 8051 integrated development software to write compiled code, for example, keil. Also it has high code running speed and low cost.
You can know more at http://www.siliconray.com/free-shipping-free-shipping-stc15f104e.html
Impression show:
#include "reg52.h"
回复删除sbit LED0 = P3^2;
sbit LED1 = P3^3;
sbit BUZZER = P3^4;
const unsigned char BUZ_TAB[30] = {1,1,2,2,3,3,4,4,5,5,
6,6,7,7,8,8,9,9,10,10,
11,11,12,12,13,13,14,14,15,15};
unsigned char cnt0 = 0,cnt1 = 0,cnt2 = 0,i = 0;
void Timer0_Init(void)
{
TMOD &= 0xf0;
TMOD |= 0x01;
TH0 = 0x4C;
TL0 = 0x0;
ET0 = 1;
TR0 = 1;
}
void Timer1_Init(void)
{
TMOD &= 0x0f;
TMOD |= 0x10;
TH1 = 0x4C;
TL1 = 0x0;
ET1 = 1;
TR1 = 1;
}
void main(void)
{
Timer0_Init();
Timer1_Init();
EA = 1;
while(1)
{
}
}
void Timer0_Ser(void) interrupt 1 using 0
{
TH0 = 0x4C;
TL0 = 0x0;
cnt0++;
cnt1++;
if(cnt0 == 10)
{
cnt0 = 0;
LED0 = ~LED0;
}
if(cnt1 == 15)
{
cnt1 = 0;
LED1 = ~LED1;
}
}
void Timer1_Ser(void) interrupt 3 using 0
{
TH1 = 0x4C;
TL1 = 0x0;
cnt2++;
if(cnt2 == BUZ_TAB[i])
{
cnt2 = 0;
BUZZER = ~BUZZER;
i++;
if(i == 30)
i = 0;
}
}