Duplicate Question
The question on this page has been marked as a duplicate question.
Original Question
Implement the design on Explorer 16 as Project 1. LED D10 will be used as the RUN LED indicator. Knight rider code: unsigned in...Question
Implement the design on Explorer 16 as Project 1. LED D10 will be used as the RUN LED indicator.
Knight rider code:
unsigned int count1 = 200;
unsigned int count2 = 200;
void main(void) {
while (1)
{
bool sw = PORTDbits.RD6;
if( toggleDirection ) {
LATA <<= 1;
}
else {
LATA >>= 1;
}
if( LATA == 0x80 ) toggleDirection = false;
if( LATA == 0x01 ) toggleDirection = true;
if( !sw ) {
if( !pressed ) {
if( toggleDirection ){
toggleDirection = false;
LATA = 0x80;
}
else {
toggleDirection = true;
LATA = 0x01;
}
pressed = true;
}
}
else {
pressed = false;
}
delayFunc();
}
return -1;
}
}
void delayFunc(void)
{
int j,k;
int a;
for(j = 0; j < count1; j++)
{
for(k=0; k < count2; k++)
{
a = 0;
}
}
}
Using the knight rider code above, do the following:
Write an simple application (in C) which does the following:
1. Make the RUN LED(D10) toggle at every 1.45 Seconds (exact) interval using one of the Timer (Timer 1) module of the Microcontroller.
2. The Knight Rider pattern now consists of 7 LEDs (D9-D3). If the switch (S3) is open, the pattern is from Left to Right direction. If the switch (S3) is closed, the pattern is from Right to Left direction.
3. Repeat the whole process in an infinite way.
4. To toggle the RUN LED, precisely at 1.45 Seconds interval, you need to use the interrupt mechanism for the Timer1.
Knight rider code:
unsigned int count1 = 200;
unsigned int count2 = 200;
void main(void) {
while (1)
{
bool sw = PORTDbits.RD6;
if( toggleDirection ) {
LATA <<= 1;
}
else {
LATA >>= 1;
}
if( LATA == 0x80 ) toggleDirection = false;
if( LATA == 0x01 ) toggleDirection = true;
if( !sw ) {
if( !pressed ) {
if( toggleDirection ){
toggleDirection = false;
LATA = 0x80;
}
else {
toggleDirection = true;
LATA = 0x01;
}
pressed = true;
}
}
else {
pressed = false;
}
delayFunc();
}
return -1;
}
}
void delayFunc(void)
{
int j,k;
int a;
for(j = 0; j < count1; j++)
{
for(k=0; k < count2; k++)
{
a = 0;
}
}
}
Using the knight rider code above, do the following:
Write an simple application (in C) which does the following:
1. Make the RUN LED(D10) toggle at every 1.45 Seconds (exact) interval using one of the Timer (Timer 1) module of the Microcontroller.
2. The Knight Rider pattern now consists of 7 LEDs (D9-D3). If the switch (S3) is open, the pattern is from Left to Right direction. If the switch (S3) is closed, the pattern is from Right to Left direction.
3. Repeat the whole process in an infinite way.
4. To toggle the RUN LED, precisely at 1.45 Seconds interval, you need to use the interrupt mechanism for the Timer1.
Answers
There are no human answers yet.
There are no AI answers yet. The ability to request AI answers is coming soon!
Submit Your Answer
We prioritize human answers over AI answers.
If you are human, and you can answer this question, please submit your answer.