Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please, i want you to modify the upper program to the situation in the second pic #include buttons.h int main(void) unsigned char blinkrate = 0;

image text in transcribed
please, i want you to modify the upper program to the situation in the second pic
image text in transcribed
#include "buttons.h" int main(void) unsigned char blinkrate = 0; // 4 rates, 0 to 3 unsigned char has_switchi_changed = 0; TRISDbits.RD1 - 1; // set RD1 as input (switch 1) while (1) has_switchl changed - monitor_switchl for edges (PORTDbits. RD1); //happens every cycle of while loop if (has_switchi_changed -- 1) //anything that should happen occasionally should be in here blinkrate++; //increment counter if (blinkrate > 3) blinkrate = 0; //cycle back to 0 //happens every cycle of while loop switch (blinkrate) // switch between blink rates case 0: // code here for pin on, delay, pin off, delay break; case 1: // code here for pin on, delay, pin off, delay break; case 2: // code here for pin on, delay, pin off, delay break; case 3: // code here for pin on, delay, pin off, delay break; 25 Modify alterBlinkRate.c to work properly and to have four rates of blinking; off, slow, moderate, and full on. For slow blinking, use a period of 0.240 s and a duty cycle of 33%, and for moderate, use a period of 0.080 s and a duty cycle of 66%. The LCD should display OFF, SLOW, MODERATE. and ON. It should only be refreshed when necessary, i.e. on the button press. Have the second toggle change the behaviour of the LEDs according to Table 4-1. Table 4-1: Two buttons making incremental changes LED behaviour Cycle up the rate of blinking of both LEDs with each depression of B1 Cycle down the rate of blinking of both LEDs with each depression of B2 #include "buttons.h" int main(void) unsigned char blinkrate = 0; // 4 rates, 0 to 3 unsigned char has_switchi_changed = 0; TRISDbits.RD1 - 1; // set RD1 as input (switch 1) while (1) has_switchl changed - monitor_switchl for edges (PORTDbits. RD1); //happens every cycle of while loop if (has_switchi_changed -- 1) //anything that should happen occasionally should be in here blinkrate++; //increment counter if (blinkrate > 3) blinkrate = 0; //cycle back to 0 //happens every cycle of while loop switch (blinkrate) // switch between blink rates case 0: // code here for pin on, delay, pin off, delay break; case 1: // code here for pin on, delay, pin off, delay break; case 2: // code here for pin on, delay, pin off, delay break; case 3: // code here for pin on, delay, pin off, delay break; 25 Modify alterBlinkRate.c to work properly and to have four rates of blinking; off, slow, moderate, and full on. For slow blinking, use a period of 0.240 s and a duty cycle of 33%, and for moderate, use a period of 0.080 s and a duty cycle of 66%. The LCD should display OFF, SLOW, MODERATE. and ON. It should only be refreshed when necessary, i.e. on the button press. Have the second toggle change the behaviour of the LEDs according to Table 4-1. Table 4-1: Two buttons making incremental changes LED behaviour Cycle up the rate of blinking of both LEDs with each depression of B1 Cycle down the rate of blinking of both LEDs with each depression of B2

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Decisions Based On Data Analytics For Business Excellence

Authors: Bastian Weber

1st Edition

9358681683, 978-9358681680

More Books

Students also viewed these Databases questions

Question

Employ effective vocal cues Employ effective visual cues

Answered: 1 week ago