


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



Lab 01
Making an LED Blink Using 89C51 Microcontroller
#include <AT89C51.H>
void wait (void){ /* wait function / ; / It does nothing, used only to implement / } / delay for LEDs */
void main (void) { unsigned int i; /* Delay variable / unsigned char j; / LED variable */
while (1) /* Loop forever / { for (j=0x01; j< 0x80; j<<=1) { / Blink LEDs 0, 1, 2, 3, 4, 5, 6 / P1 = j; / send Output to Port 1 */
for (i = 0; i < 10000; i++) { /* Delay for 10000 Counts / wait (); / call wait function */ } }
for (j=0x80; j> 0x01; j>>=1) { /* Blink LED 6, 5, 4, 3, 2, 1 / P1 = j; / Output to LED Port / for (i = 0; i < 10000; i++) { / Delay for 10000 Counts / wait (); / call wait function */ } } }