User Tools

Site Tools


notes:c4eng:fall2024:projects:ptb0

This is an old revision of the document!


PTB0

LED

GPIO MODE SETTING

GPIO COMMAND-LINE TESTING

wiringPi: digitalWrite()

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, HIGH);

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, LOW);

The voltage to the pin will be interrupted, and the LED light will shut off.

pico: gpio_put()

The gpio_put() function is a command given to the computer relating to the input of a statement. The “gpio” corresponds to the gp-pin of the pico designated for the code to run through, with “put” being the command that tells the computer that a code is to be “put” into the command. An example is the wiring of an LED; the LED will only be lit up with the gpio_put () function if its “power” wiring is correctly placed in the denoted gp-pin.

BUTTON

GPIO MODE SETTING

VERIFYING CORRECT CIRCUIT CONNECTION

wiringPi: digitalRead()

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.

notes/c4eng/fall2024/projects/ptb0.1728669538.txt.gz · Last modified: 2024/10/11 17:58 by dprado