User Tools

Site Tools


notes:c4eng:fall2024:projects:ptb0

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
notes:c4eng:fall2024:projects:ptb0 [2024/10/11 17:58] – [wiringPi: digitalWrite()] dpradonotes: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 "pinMode (LED, OUTPUT);". The "LED" factor in the parentheses is simply whatever variable name you assigned to the LED pin when you initialized it.
 ====GPIO COMMAND-LINE TESTING==== ====GPIO COMMAND-LINE TESTING====
 ====wiringPi: digitalWrite()==== ====wiringPi: digitalWrite()====
Line 22: Line 23:
  
 ====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 "pinMode (button, OUTPUT);". The "button" factor in the parentheses is simply whatever variable name you assigned to the button pin when you initialized it.
 ====VERIFYING CORRECT CIRCUIT CONNECTION==== ====VERIFYING CORRECT CIRCUIT CONNECTION====
 ====wiringPi: digitalRead()==== ====wiringPi: digitalRead()====
 +While digitalWrite() will send voltage to a gpio pin in "output" mode in order to power a component such as an LED light, the digitalRead() function will read the digital state of a gpio pin in "input" mode. The function will return "HIGH," "True," or "1" if there is an input. If there is no iutput, the function will return "LOW," "False," or "0."
 ====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 "gpio" corresponds to the gp-pin of the pico designated for the code to run through, with "get" being the command that tells the computer that a code is to be "pulled" from the command. The code the computer needs to "get" must be the same code given to the computer in the corresponding gpio_put () function written in the same command box. An example is the use of a button to light up an LED; the LED is given a designated gp-pin to be wired to, but the gpio_get () function can tell the computer that the LED should only be lit it if the wired button is pushed down, and turned off when the button is released. 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 "gpio" corresponds to the gp-pin of the pico designated for the code to run through, with "get" being the command that tells the computer that a code is to be "pulled" from the command. The code the computer needs to "get" must be the same code given to the computer in the corresponding gpio_put () function written in the same command box. An example is the use of a button to light up an LED; the LED is given a designated gp-pin to be wired to, but the gpio_get () function can tell the computer that the LED should only be lit it if the wired button is pushed down, and turned off when the button is released.
notes/c4eng/fall2024/projects/ptb0.1728669538.txt.gz · Last modified: 2024/10/11 17:58 by dprado