-
Notifications
You must be signed in to change notification settings - Fork 0
License
chenphilip888/rpi3b-python-gpio
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Python gpio experiments on Raspberry PI 3B board. The following 7 tests are included: ( see below for tests summary ) 1. led test 2. button test 3. pwm led test 4. i2c lcd test 5. tongsong 6. servo 7. spi oled test ------------------------------------------------------------------- To compile and flash to sd card: cd rpi3b-python-gpio Download OS: wget https://downloads.raspberrypi.org/raspios_lite_armhf/images/raspios_lite_armhf-2021-01-12/2021-01-11-raspios-buster-armhf-lite.zip unzip 2021-01-11-raspios-buster-armhf-lite.zip Use balenaEtcher to burn img to sd card. eject sd card. Plugin sd card to PC. To enable SPI add dtparam=spi=on in /boot/config.txt sudo cp config.txt /media/$USER/boot sync sudo umount /media/$USER/boot eject sd card. Plugin the sd card to Raspberry PI 3B board. Connect gpio Pin 8 to serial USB cable TX. Connect gpio pin 10 to serial USB cable RX. Connect gpio pin 39 to serial USB cable ground. Type "script ~/outputfile.txt" on PC. Plugin serial USB cable to PC. Type "sudo screen /dev/ttyUSB0 115200" on PC. Power on Raspberry PI 3B board. It should prompt login message. user pi password raspberry sudo raspi-config set password, wifi, locale, timezone, peripheral, enable ssh etc. reboot Power off Raspberry PI 3B board. ( console output garbage due to bluetooth, need to use ssh ) Unplug serial USB cable from PC. Type "exit" on PC. Power on Raspberry PI 3B board. ssh pi@192.168.86.xxx sudo ifconfig sudo apt-get update sudo apt-get upgrade sync sudo reboot sudo apt-get install python-dev python-pip python-setuptools python3-dev python3-pip python3-setuptools dnsutils apache2 vsftpd ftp git python-smbus i2c_tools sudo i2cdetect -y 1 Download gpio library on Raspberry PI 3B board: wget https://project-downloads.drogon.net/wiringpi-latest.deb sudo dpkg -i wiringpi-latest.deb gpio -v ( make sure it's v2.52 or above ) gpio readall sudo pip install serial pyserial spidev git clone https://github.com/doceme/py-spidev.git cd ~/py-spidev sudo python setup.py install sudo python3 setup.py install cd ~/ git clone https://github.com/chenphilip888/rpi3b-python-gpio.git cd ~/rpi3b-python-gpio chmod 755 gpio_test.py sudo ./gpio_test.py When done all tests, hit 'q' to exit tests. sudo shutdown -h now Power off Raspberry PI 3B board. ------------------------------------------------------------------------- Here are the summary of the tests: ( see https://pi4j.com/1.2/pins/model-3b-rev1.html ) These tests used Seeed Grove starter kit LED, button, buzzer, Grove-LCD RGB Backlight V3.0 JHD1313M2, Analog Servo and Adafruit SSD1306 128x32 SPI OLED Display. 1. led test. This test will blink led 5 times. Connect gpio pin 18 to led control. Connect gpio pin 2 to led 5V. Connect gpio pin 9 to led ground. 2. button test. Connect gpio pin 18 to led control. Connect gpio pin 2 to led 5V. Connect gpio pin 9 to led ground. Connect gpio pin 16 to button control. Connect gpio pin 4 to button 5V. Connect gpio pin 6 to button ground. 3. pwm led test. This test will dim led 10 times. Connect gpio pin 33 to led control. Connect gpio pin 2 to led 5V. Connect gpio pin 9 to led ground. 4. i2c lcd test. This test will change lcd backlight color for 5 cycles. Then it will display two sentences on lcd display. Connect gpio pin 3 to lcd display SDA. Connect gpio pin 5 to lcd display SCL. Connect gpio pin 2 to lcd display 5V. Connect gpio pin 9 to lcd display ground. 5. tongsong. This test will generate song using buzzer. Connect gpio pin 33 to buzzer control. Connect gpio pin 2 to buzzer 5V. Connect gpio pin 9 to buzzer ground. 6. servo. This test will turn servo 90 degree - 180 degree - 90 degree - 0 degree etc. Connect gpio pin 33 to servo control. Connect gpio pin 2 to servo 5V. Connect gpio pin 9 to servo ground. 7. spi oled test. This test will show some ascii characters on the oled display. Connect gpio pin 18 to oled display DC. Connect gpio pin 24 to oled display CS. Connect gpio pin 19 to oled display TX. Connect gpio pin 23 to oled display CLK. Connect gpio pin 1 to oled display 3.3V. Connect gpio pin 9 to oled display ground. -----------------------------------------------------------------------------
About
No description, website, or topics provided.
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published