This folder contains example Python code to use the Pi Camera and General Purpose Input and Output (GPIO) pins. To use the code samples:
- Download the code samples onto your Raspberry Pi.
- Follow the wiring diagrams in the schematics folder.
- Download code libraries using pip. For example:
sudo pip install gpiozero
- Open the code sample in your preferred Python editor
- Make any required updates as indicated in the code sample comments.
- Run the program!
- Run the sample programs with Python3:
sudo python3 program_name.py
- Run the sample programs with Python3:
- Sample Python programs with the GPIO Zero library (e.g. blink an LED, pushbutton input, and more)
- Image Capture with the Pi Camera in Python (Raspberry Pi Foundation)
- Pi Camera Image Capture with a Pushbutton: pushbutton_image_capture.py
- Pi Servo Control:
- servo_control.py
- servo_control_angular.py
Note: Please check the spec of your servo for the max angle and modify the max/min angles in the code accordingly. - servo_control_noJitter.py
Note: You will need to install a library before running the example
sudo pip3 pigpio
Before you run the code, please run the following command in terminal first
sudo pigpiod
Check the schematics folder for wiring diagrams for relevant examples.
All schematics were made with Fritzing.
All of the following resources are created and maintained by the Raspberry Pi Foundation.
As mentioned in the main README, we welcome contributions! Please read through the README and Code of Conduct to submit a pull request.
Please open an issue if you have questions or requests!