Arduino-NodeJS-360-Video-Player

In this project, I created a 360 video player (currently playing a demo mp4 file) and a controller with Arduino UNO.

Watch Demo Video (youtube)

Requirements:

Build Arduino controller

For making the arduino controller you need the Arduino development board and a ITG/MPU 3-axis Acc. and Gyro. sensor board (I am using GY-521 here). Follow the circuit diagram below to build your circuit.

Arduino and GY521 Circuit Diagram

Once the cicruit is build, we need to program the micro-controller. Download the script and open it in ArduinoIDE or any IDE of your choice and flash it to the arduino.

Now you can open up a serial console and check if your arduino is giving you the desired output or not. The output should look something like this:

91,46,-154
109,57,-152
98,21,-156
104,35,-171
96,51,-149
124,52,-142
118,66,-155

After we have done this we need to change the code of our index.ts in the /server/script folder.

Open the file and look for the variable portname and change it to the port to which your arduino is connect. For me it would be:

// Defining the port name: This is the port to which your arduino is connected.
// Change it to the name of the port to which you have connected your arduino
const portName = 'COM10';

Now we are done with the controller part. Lets to some Typescripting now and build our server and client.

Build Server and Client script

To build the server-side code, follow these steps:

Note: The start command automatically builds the TS files as well, so you cant skip the build step and directly run the start command.


For building the client, do the following changes:

Change the url for socket connection to local host as follows:

http://127.0.0.1:[socket port number]/[socket prefix]

For me it would be:

//socket connection from the server
let sock = new SockJS("http://127.0.0.1:3000/arduino");

Once this is done, run the following command in the www folder:

tsc

Go though the generate JS files and remove the lines that are surrounded by the remove comment block

Finally,

Gallery

Arduino with Prototyping shield and GY521Arduino with Prototyping shield and GY521Arduino with Prototyping shield and GY521