Introduction: Simplest and Cheapest Control Circuit of LED and Buzzer in History

Picture of Simplest and Cheapest Control Circuit of LED and Buzzer in History
What is the simplest and cheapest LED and buzzer controlled by MCU? 
It’s LED control system based STC15F104E!
MCU:$1.2
LED:$0.12
Buzzer:0.3
Capacity:0.1
Connector:0.1
Only $1.8

I have made one, now I will have a brief description.
schematic diagram:
See pictured above

 Assembly list:

STC15F104E
Capacity
Resistance
LED
buzzer
Interface


Brief introduction:
The circuit uses an integrated STC15F104E 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; 

}

Comments

Ayoiezio (author)2015-03-23

I have a question, how to make a led that changing light from red to green and when the led turn green a buzzer will trigger? I want to make a phone charger project, that when the phone fully charged led with green color that controlled by microcontroller will on and the buzzer also trigger