Question: #include #include int timeg = 5000; // Declare and initialize time for Green LED as 5000 ms int timey = 2000; // Declare and initialize

#include #include int timeg = 5000; // Declare and initialize time for Green LED as 5000 ms int timey = 2000; // Declare and initialize time for Yellow LED as 2000 ms int timer = 5000; // Declare and initialize time for Red LED as 5000 ms void delay(int); // Function to generate as per the variable passed int main() { // Port D configured as output int TRISD = 0; while (1) { // Green LED ON int PORTD = 4; delay(timer); // As per value of variable for green LED generate delay // Yellow LED ON PORTD = 2; delay(timey); // As per value of variable for yellow LED generate delay // Red LED ON PORTD = 1; delay(timeg); // As per value of variable for red LED generate delay } return 0; } void delay(int n) { // Function which generate n milli seconds int i; for (i = 0; i < n; i++) { // Generate 1 ms delay n times to generate n milli seconds delay int Delay_ms = 1; } }

Can you detect the errors in this code and rewrite it in the same language?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!