This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
notes:c4eng:fall2024:projects:ptb0 [2024/10/10 12:31] – [pico: gpio_get()] dnayo | notes:c4eng:fall2024:projects:ptb0 [2024/10/12 19:43] (current) – [GPIO MODE SETTING] skephart | ||
---|---|---|---|
Line 5: | Line 5: | ||
====GPIO MODE SETTING==== | ====GPIO MODE SETTING==== | ||
+ | In order to allow for the LED that is connected to the circuit to be turned on and off through the code of the program we need to change the mode of the pin that the LED is connected through, to output. We do this through the line of code " | ||
====GPIO COMMAND-LINE TESTING==== | ====GPIO COMMAND-LINE TESTING==== | ||
====wiringPi: | ====wiringPi: | ||
+ | The digitalWrite() command is used to run power to a desired gpio pin. If the pin is in OUTPUT mode and you have a desired gpio pin set to some name (in this example, LED_PIN), then typing the command | ||
+ | |||
+ | digitalWrite(LED_PIN, | ||
+ | |||
+ | will send voltage to that pin to power whatever is hooked up to it. If there is an LED light, then the command will cause the LED to illuminate. | ||
+ | The command can also be used to shot off a pin in output mode. By typing | ||
+ | |||
+ | digitalWrite(LED_PIN, | ||
+ | |||
+ | The voltage to the pin will be interrupted, | ||
====pico: gpio_put()==== | ====pico: gpio_put()==== | ||
- | The gpio_put() function is a command given to the computer relating to the input of a statement. The " | + | The gpio_put() function is a command given to the computer relating to the input of a statement. The " |
=====BUTTON==== | =====BUTTON==== | ||
====GPIO MODE SETTING==== | ====GPIO MODE SETTING==== | ||
+ | In order to allow for the button that is connected to the circuit to be used as an actual input for the code and to power the light through the code of the program for ptb0 we need to ensure that the mode of the pin the button is connected to is set to input. We do this through the line of code " | ||
====VERIFYING CORRECT CIRCUIT CONNECTION==== | ====VERIFYING CORRECT CIRCUIT CONNECTION==== | ||
====wiringPi: | ====wiringPi: | ||
+ | While digitalWrite() will send voltage to a gpio pin in " | ||
====pico: gpio_get()==== | ====pico: gpio_get()==== | ||
- | The gpio_get() function is a command given to the computer relating to the output of a statement and is the opposite of the gpio_put() function. The " | + | The gpio_get() function is a command given to the computer relating to the output of a statement and is the opposite of the gpio_put() function. The " |