Question 2 (40 points) Write a C program to do the following: - . A green LED is blinking (on 1 second, off 1 second) Every time a magnet is detected, the blinking becomes slower (on 2 seconds off 2 seconds) and a red LED turns on and stays on as long as the magnet is close Once the magnet is removed, only the green LED blinks again (on 1 second, off 1 second) . Use GPIO2 for green LED, GPIO3 for red LED, and GPIO4 for the Reed Switch. Show the connections from the elements to Raspberry Pi in the picture below. Make sure you include the necessary ground (GND) and Vec (3.3V) connections. use of the Counter?? # Include
Volatile int counter.o # Include counter t int main C) what is Riotorte wiring Pisetup(); Pin Mode (2, OUTPUT); Il green Pin Mode (3, OUTPUT); // red Pin Mode (4, INPUT); Il Reed switch output for (;;) E (digital Read (4) == 1) if (Digital feadfoot) & digital Write 13, Low), digital Write (2, HIGH); delay (1000); digital Write ( 2, Low); z delay (1000); else e digital Write (3, HIGH); delay (2000); digital Write (3, how); Question 2 (40 points) Write a C program to do the following: - . A green LED is blinking (on 1 second, off 1 second) Every time a magnet is detected, the blinking becomes slower (on 2 seconds off 2 seconds) and a red LED turns on and stays on as long as the magnet is close Once the magnet is removed, only the green LED blinks again (on 1 second, off 1 second) . Use GPIO2 for green LED, GPIO3 for red LED, and GPIO4 for the Reed Switch. Show the connections from the elements to Raspberry Pi in the picture below. Make sure you include the necessary ground (GND) and Vec (3.3V) connections. use of the Counter?? # Include Volatile int counter.o # Include counter t int main C) what is Riotorte wiring Pisetup(); Pin Mode (2, OUTPUT); Il green Pin Mode (3, OUTPUT); // red Pin Mode (4, INPUT); Il Reed switch output for (;;) E (digital Read (4) == 1) if (Digital feadfoot) & digital Write 13, Low), digital Write (2, HIGH); delay (1000); digital Write ( 2, Low); z delay (1000); else e digital Write (3, HIGH); delay (2000); digital Write (3, how)