$30
Assignment
1. Write a program in C that achieves the following tasks:
a. Interface SW1 and SW2 as inputs.
b. Interface LED1 and LED2 as outputs. Both LEDs should be ‘ON’ at the beginning of program.
c. Detect pressing of SW1 and/or SW2.
i. If SW1 is pressed, blink LED1 at 5Hz. (You should show your calculation for exact timing generation in your report and present it to instructor during demo. Please look at demo 2 for hint.). LED1 should go to ON state if SW1 is released. ii. If SW2 is pressed, blink LED2 at 2Hz. (You should show your calculation for exact timing generation in your report and present it to instructor during demo.). LED2 should go to ON state if SW2 is released.
iii. If none of the switches are pressed, both LED should be constantly in ON state.
2.If SW1 and SW2 are both pressed, blink LED1 and LED2 at 1Hz. Both LEDs should be ON if switches are released. State of both switches being pressed can be achieved either by pressing both the switches at once, or by pressing a switch when holding other one. (For e.g., pressing SW1 when holding SW2 should blink both LEDs at 1Hz. Releasing any one of the switches should meet the condition as described in 2c above.)