Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#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

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_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions

Question

Describe the French influence on our culinary heritage.

Answered: 1 week ago

Question

What is the relationship between humans?

Answered: 1 week ago

Question

What is the orientation toward time?

Answered: 1 week ago