gpio_led_control
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| gpio_led_control [2016/08/09 17:20] – walkeradmin | gpio_led_control [2017/10/22 15:40] (current) – walkeradmin | ||
|---|---|---|---|
| Line 8: | Line 8: | ||
| \\ | \\ | ||
| \\ | \\ | ||
| - | **Please be aware, the GPIO pins are 3.3v Logic, and are restricted to 16mA** | + | **Please be aware, the GPIO pins are 3.3v Logic, and are restricted to 16mA - exceeding 16 mA will damage your Pi** |
| \\ | \\ | ||
| \\ | \\ | ||
| Line 25: | Line 25: | ||
| If you are using your Raspberry Pi via SSH or a Remote Desktop session, you need to enable remote access of the GPIO Pins, instructions for this are [[enable_remote_access_to_gpio_pins|here]]: | If you are using your Raspberry Pi via SSH or a Remote Desktop session, you need to enable remote access of the GPIO Pins, instructions for this are [[enable_remote_access_to_gpio_pins|here]]: | ||
| \\ | \\ | ||
| - | sudo raspi-config | + | \\ |
| - | + | Once you have connected the circuit, we can create the Python programme, in this example we will be doing it from the command line using the editor nano: | |
| - | | + | \\ |
| - | | + | |
| - | | + | \\ |
| - | | + | Now enter this code: (you can copy and paste by the way) |
| - | | + | \\ |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | # These libraries are built in to Raspbian. |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | # so we can reference it by using BOARD as pin 12. However there is |
| - | | + | # another option (BCM) where we can reference a pin by it's name, pin |
| - | | + | # 12 is called GPIO18 (a reference |
| - | | + | |
| - | | + | GPIO.setup(12, |
| + | # read in a voltage (but only in terms of a 0 or a 1)) | ||
| + | | ||
| + | GPIO.output(12, | ||
| + | | ||
| + | time.sleep(1) | ||
| + | | ||
| + | GPIO.output(12, | ||
| + | |||
| + | | ||
| + | |||
| + | | ||
| + | \\ | ||
| + | \\ | ||
| + | Because we are accessing the GPIO, we need to run our Python program as the sudo user: | ||
| + | \\ | ||
| + | | ||
| + | \\ | ||
| + | The LED should come on for 3 seconds, then go off. The program will then end. | ||
| + | \\ | ||
| + | \\ | ||
| + | You can see it in operation Here: {{: | ||
| + | \\ | ||
| + | **Remember: | ||
| - | Advanced Options: | + | Pins are 3.3v |
| - | + | ||
| - | ┌──────────────────┤ Raspberry Pi Software Configuration Tool (raspi-config) ├───────────────────┐ | + | |
| - | │ │ | + | |
| - | │ A1 Overscan | + | |
| - | │ A2 Hostname | + | |
| - | │ A3 Memory Split | + | |
| - | │ A4 SSH Enable/ | + | |
| - | │ A5 SPI Enable/ | + | |
| - | │ A6 I2C Enable/ | + | |
| - | │ A7 Serial | + | |
| - | │ A8 Audio Force audio out through HDMI or 3.5mm jack ▒ │ | + | |
| - | │ A9 1-Wire | + | |
| - | │ AA GPIO Server | + | |
| - | │ │ | + | |
| - | │ │ | + | |
| - | │ < | + | |
| - | │ │ | + | |
| - | └────────────────────────────────────────────────────────────────────────────────────────────────┘ | + | |
| - | + | ||
| - | Select GPIO Server | + | |
| - | + | ||
| - | | + | |
| - | | + | |
| - | │ Would you like the GPIO server to be accessible over the │ | + | |
| - | │ network? | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | + | ||
| - | You will get a confirmation that the GPIO Server is available. | + | |
| - | + | ||
| - | ┌──────────────────┤ Raspberry Pi Software Configuration Tool (raspi-config) ├───────────────────┐ | + | |
| - | │ │ | + | |
| - | │ 1 Expand Filesystem | + | |
| - | │ 2 Change User Password | + | |
| - | │ 3 Boot Options | + | |
| - | │ 4 Wait for Network at Boot Choose whether to wait for network connect | + | |
| - | │ 5 Internationalisation Options | + | |
| - | │ 6 Enable Camera | + | |
| - | │ 7 Add to Rastrack | + | |
| - | │ 8 Overclock | + | |
| - | │ 9 Advanced Options | + | |
| - | │ 0 About raspi-config | + | |
| - | │ │ | + | |
| - | │ │ | + | |
| - | │ < | + | |
| - | │ │ | + | |
| - | └────────────────────────────────────────────────────────────────────────────────────────────────┘ | + | |
| - | + | ||
| - | Now Select Finish - You will be back at the command prompt (you may need to reboot) | + | |
| \\ | \\ | ||
| + | 16mA MAX | ||
| \\ | \\ | ||
| + | \\ | ||
| + | This guide is comprised of information from a youtube video by **Gaven MacDonald**. Thanks Gaven. | ||
| + | \\ | ||
| + | \\ | ||
| + | |||
gpio_led_control.1470763221.txt.gz · Last modified: (external edit)
