RPi Demo using Python3 that shows a sensor sensing and a motor moving using a Proportional-Integral-Derivative (PID) controller.
- Flash Raspbian lite to SD card, current version is Raspbian Buster
- Add empty file named "ssh" to root directory of SD card, to enable ssh
- Insert card into RPi and boot up for the first time
- Use another computer to SSH into RPi, ssh pi@192.168.1.[rpi_ip]. Default password is raspberry and it's always a good idea to change that right away with passwd command
- Update things with *sudo apt update && sudo apt upgrade
- sudo apt install git
- git clone https://github.com/dancj/pid_distance_control.git
- Now this project is on the RPi, just need to set up virtual environment and download dependencies
- cd pid_distance_control/
- sudo apt install python3-venv
- python3 -m venv venv
- source venv/bin/activate
- pip install -r requirements.txt
- Uses pigpiod library to communicate with distance sensor, which needs to be installed:
- sudo apt install pigpiod
- Flash Raspbian lite to SD card, current version is Raspbian Buster
- Add empty file named "ssh" to root directory of SD card, to enable ssh
- Insert card into RPi and boot up for the first time
- Use another computer to SSH into RPi, ssh pi@192.168.1.[rpi_ip]. Default password is raspberry and it's always a good idea to change that right away with passwd command
- Update things with *sudo apt update && sudo apt upgrade
- Install Docker: curl -sSL https://get.docker.com | sh
- Update user permissions: sudo usermod -aG docker pi
- Run this project's container (TBD): docker run armhf/hello-world
Just need to run the main python routine
- cd pid_distance_control/
- source venv/bin/activate
- sudo pigpiod
- python src/run.py
- Raspberry Pi (RPi) 1 model B (could use any model, this is just the one I had available)
- Use cat /proc/cpuinfo | grep model to show processor version. This indicates which Docker base image is needed
- Ultrasonic distance sensor (HC-SR04)
- This sense transmits a sound wave out of its transitter, then receives the reflected wave in its receiver
- Servo motor
- Cobbler Pi breakout board
- Half size breadboard
- Jumper wires
- Resistors: 330 and 470 Ohm
- Using a Raspberry Pi distance sensor
- Raspberry Pi Servo Motor control
- Ultrasonic sensor tutorial
- Sonar Ranger pigpio example
This is for a class extra credit project, but mostly just for fun.
Put out there to the world "as is" with MIT license.