Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a C-language program that runs on the AT89C51CC03 board. Add four LEDs to

ID: 2247942 • Letter: W

Question

Write a C-language program that runs on the AT89C51CC03 board. Add four LEDs to your board to P1.0, P1.1, P1.2, and P1.3 and add a push button switch to the board on P3.4. All resistors are 1K. For this problem you are going to multiplex the LEDs so that they appear to be all on when the switch is pushed but your program will only turn on one LED at a time. The blink rate of the eye is about a thirtieth of a second - that is, you can see something blinking if it is blinking at a rate slower than about 30 times s second - but this is brightness dependent. For this problem we will take the blink rate to be about 50 times second. Since we have four LEDs you will have to turn on the first, then turn it off and turn on the second, turn that off and turn on the third, turn that off and turn on the fourth all in a 50th of a second (20 msec). Since there are four LEDs each LED will be on for just 5 milliseconds. When the switch is pushed you will run a loop that turns on the next LED every 5 msec. Your program should use a function which accepts an unsigned character argument named x and does a software delay of x msec. Do a demo of your program in class on the due date and turn in the following: 1. A cover sheet with your name, assignment number, and the date turned in. 2. A hard copy of your commented assembly-code

Explanation / Answer

8051 c program;

=====================

#include<htc.h>

//Function declarations

void delay_msec(unsigned int);

// Main function

int main(void)

{

P1=0x00;

if(1)

while(1) // Rest is done in Timer0 interrupt

{

P1 = 0x01; // Make out pin high

delay_msec(5); // Generate a delay of 5 msec

P1 = 0x00; // Make out pin low

delay_msec(5); // Generate a delay of 5 msec

P1 = 0x02; // Make out pin high

delay_msec(5); // Generate a delay of 5 msec

P1 = 0x00; // Make out pin low

delay_msec(5); // Generate a delay of 5 msec

P1 = 0x04; // Make out pin high

delay_msec(5); // Generate a delay of 5 msec

P1 = 0x00; // Make out pin low

delay_msec(5); // Generate a delay of 5 msec

P1 = 0x08; // Make out pin high

delay_msec(5); // Generate a delay of 5 msec

P1 = 0x00; // Make out pin low

delay_msec(5); // Generate a delay of 5 msec

}

}

void delay_msec(unsigned int x){

while(x>0){

unsigned int y=83.33; // generating 1 ms delay

while(y>0)

y--;

x--;

}

}

==================

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote