Getting Started Read the code and the comments carefully to understand each step
ID: 3702750 • Letter: G
Question
Getting Started Read the code and the comments carefully to understand each step of the program. The program uses a simple loop (k100000000) loop as a delay to slow the changes sent to the LEDs to allow us to see them. As a first exercise, modify the for loop to wait a much shorter time by changing the value 100000000 to 1000 and run the program again. You will see that the speed has increased to the point where all the LEDs appear to be lit and flashing. Deiine 8051 regiatera/ vold aan tvosa: unaigned int i Delay variable/ whilei Loop fozevex/ 3 0x00: tor (i-100000000; ¡>0; i- Output FF to the TED Port / Output 00 to the LED Port/ /End while(1) 1oop / End of main/ Exercise 1 Extend the supplied example to light all LEDs Later, in exercise 5, you will need to create a rotating bit pattern, rather than one going up and then down. This will be harder as the variable you'll be using will hold 16-bits, but you will only be working with the bottom 8.Explanation / Answer
#include<reg51.h>
void main(void)
{
unsigned int i;
while(1)
{
P3=0x00;
for(i=1000;i>0;i--)
P0=0xff;
for(i=1000;i>0;i--)
P0=0x00;
}
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.