Write a program, led_pb.c, compiled with GCC on the RPi 3b/3b+, that performs the following steps using the provided sysfs_gpio files: a. Include the sysfs_gpio.h file b. Initializes the LED pin to be an output by calling gpioOutput() c. Initializes the switch pin to be an input by calling gpioInput() d. Turns on the LED using gpioWrite() e. Enters a while loop that calls gpioRead() and waits for the switch to read 1 f. Turns off the LED using gpioWrite() sysfs_gpio.h : #ifndef SYSFS_GPIO_H_ #define SYSFS_GPIO_H_ // Called to configure the pin as an input or output void gpioOutput(int pin); void gpioInput(int pin); // Called to set and output pin to a given value (1 or 0) void gpioWrite(int pin, int value); // Called to get the status (1 or 0) of a pin int gpioRead(int pin); #endif
Write a program, led_pb.c, compiled with GCC on the RPi 3b/3b+, that performs the following steps
using the provided sysfs_gpio files:
a. Include the sysfs_gpio.h file
b. Initializes the LED pin to be an output by calling gpioOutput()
c. Initializes the switch pin to be an input by calling gpioInput()
d. Turns on the LED using gpioWrite()
e. Enters a while loop that calls gpioRead() and waits for the switch to read 1
f. Turns off the LED using gpioWrite()
sysfs_gpio.h :
#ifndef SYSFS_GPIO_H_
#define SYSFS_GPIO_H_
// Called to configure the pin as an input or output
void gpioOutput(int pin);
void gpioInput(int pin);
// Called to set and output pin to a given value (1 or 0)
void gpioWrite(int pin, int value);
// Called to get the status (1 or 0) of a pin
int gpioRead(int pin);
#endif
Trending now
This is a popular solution!
Step by step
Solved in 2 steps