Difficulty: Intermediate
Components: 7 LEDs (arranged like a dice face), 7x 220Ω resistors, 1 push button
This classic project randomizes a number between 1 and 6 and lights up the corresponding LEDs on a dice pattern.
Compare two voltages on P1.0 (AIN0) and P1.1 (AIN1). Output to P3.6. at89c2051 projects
P1 |= 0x03; // disable digital input on P1.0/P1.1
CMOD = 0x00;
CON = 0x00; // no interrupt
while(1)
if(CON & 0x20) // comparator output
P3_6 = 1;
else
P3_6 = 0;
UART communication
Send back any character received via RxD (P3.0) to TxD (P3.1).
Baud rate: 9600, 11.0592 MHz crystal.
void uart_init()
TMOD = 0x20; // Timer1 mode2
TH1 = 0xFD; // 9600 baud
SCON = 0x50; // 8-bit UART, enable receive
TR1 = 1;
Connect an LED with a 220Ω series resistor between P1.0 and GND. Difficulty: Intermediate Components: 7 LEDs (arranged like a
Difficulty: ★★★☆☆
The AT89C2051 lacks an Analog-to-Digital Converter (ADC). However, it has a built-in analog comparator. This project uses an RC charge-discharge method to measure analog voltage. UART communication Send back any character received via
Concept: Measure the output of an LM35 temperature sensor (10mV/°C).
User Interface: Three LEDs (Blue = Cold, Yellow = Normal, Red = Hot).
The Challenge: Writing the timing code without a hardware timer overflow is tricky but immensely satisfying. This project teaches you how to implement a Software ADC.
Limitations: No internal ADC, no PWM module, no external data memory bus (no P0/P2).