Controlling servomotor with Create React App and Node Js.
- Raspberry pi
- Node Js
- pigpio C library
Open a terminal on your machine and do the following:
- Clone this repository
- Run
npm install
in project root - Move the server folder to your raspberry pi.
- On the raspberry Pi
- Install pigpio by running
sudo apt-get install pigpio
- Ensure node js is installed
- Navigate into the server folder and run
npm install
- Run
npm start
to start the backend server at https://localhost:5000 - This code works with the yellow servomotor wire connected to pin 17. Edit server.js to in case you want to use a different pin.
- Install pigpio by running
- On the raspberry Pi
- Navigate back to the project root and run
npm start
to start the frontend server at https://localhost:3000. - Edit Rotate.js and replace
your_raspberry_pi_address
wih your actual pi address.
- Check out Node Schedule for cron-like scheduling.
- Check out Pigpio to control other devices on the pi using js such as accelerometers, LEDs and ultrasonic sensors