Giter Club home page Giter Club logo

raspberry-pi-4-servo-with-joystick-using-cpp's Introduction

Moving a Micro Servo with a Joystick Using C++ and a Raspberry Pi 4B

A project based on C++ that uses a Raspberry Pi 4B Rev. 1.2 board to move a micro servo with a joystick. For GPIO pin mapping, I used WiringPi (Made by Gordon Henderson under GNU-LGPL) to simplify. Link: http://wiringpi.com/

WiringPi Note: The author has discontinued public releases of WiringPi. The last update was 2.52 for the Raspberry Pi 4B. Although WiringPi is preinstalled on Raspbian systems, the code for installation is as follows:

sudo apt-get install wiringpi

Use:

gpio -v

to check if your version is 2.52.

For more details visit http://wiringpi.com/download-and-install/

To upgrade, visit http://wiringpi.com/wiringpi-updated-to-2-52-for-the-raspberry-pi-4b/

A C library for the ADC Device is required. It needs to be installed through the terminal. The folder is included in the repository. Opening a terminal in the folder location or using "cd" to access it, run the code to build:

sudo bash
sh ./build.sh 

Hardware components used:

  • (1) 5 pin Joystick
  • (1) Tower Pro Micro Servo 9g
  • (1) ADC Module (PCF8591)
  • (3) 10K Resistors
  • (1) Breadboard
  • (21) Jumper Cables
  • Raspberry Pi 4B Rev. 1.2

When compiling the code, run the following commands in terminal at the location of the file:

sudo bash
g++ ServoJoystick.cpp -o ServoJoystick -lwiringPi -lADCDevice
./ServoJoystick

This project was possible through an electronics kit I purchased from Freenove that provided me with all of the components I used. If interested, it is the "Freenove Ultrasonic Starter Kit for Raspberry Pi" (FNK0024).

raspberry-pi-4-servo-with-joystick-using-cpp's People

Contributors

christophermilian avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.