Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Use a button and an LED and write a program to implement the following: - When t

ID: 3753797 • Letter: U

Question

Use a button and an LED and write a program to implement the following:

- When the button is pushed and released, the program counts the number of seconds the button was pushed.

- If the button was pushed less than a second, after the button is released it prints the message "The push was not long enough!"

- If the button is pushed more than a second, after the button is released it makes the LED blink. The number of times the LED blinks is equal to the number of seconds the button was pushed.

must use #include <stdio.h> and #include <wiringPi.h>, show comments.

Explanation / Answer

#include<stdio.h> //i/o library

#include <time.h>

int main(){

clock_t start, end;

int pushed_button_time;

int button;

if(button==1){

start = clock();

if()

end = clock();

pushed_button_time = ((double) (end - start)) / CLOCKS_PER_SEC;

}

if(pushed_button_time<1)

printf("The push was not long enough!");

else

while(pushed_button_time>0)

{

blinkLED(); //Thhe function to blick LED can be implemented here.

}

return 0; //This is to make sure that the program terminates

}