Here is what the final product will look like.
Wiring Up The Board
First we set up the initial layout of the board, we have the joystick at the bottom, with a pinhole left over on each side. Then we have two push buttons representing the two buttons on a normal mouse. We have the buttons staggered so we can read the value independently.
Next, we're going to wire up the push buttons, connecting one pin on each of the buttons to ground, and the other pin on each of them to the digital pins ["D2", "D3"], we wire the left button to pin "D3" and the right button to pin "D2".
Third we're going to wire up the joystick. It is a little bit difficult to see where the wires should go, but I'm sure you'll get it sooner or later, take your time. We connect the pin on the joystick that reads "GND" to ground. Then we connect the two pins that read "L/R+" and "U/D+" to power which then runs to pin "3V3" on the Pinoccio scout.
Then we're going to wire up the pins that read "L/R" and "U/D" on the joystick to analog pins "A0" and "A1".
That's it for wiring!!
Now To CODE!
The code for the mouse is written in Node.js using Johnny-Five. So we're gonna start up our terminal, and run a few commands to get out project running.
First let's run:
To startup our project. Go through all the steps to getting our initial project started. For this project we're using three Node Packages:
So let's get going to install these packages. We need to run:
npm install pinoccio-io
npm install johnny-five
npm install NodObjC
Now open up the newly created index.js in your favorite text editor, I prefer Sublime Text, but it's up to you. At the top of index.js we're gonna require our three packages that we installed earlier.We also need to install a NodeObjC framework called Cocoa to manipulate the mouse cursor on our Mac.
Ok so now that we have that going let's initialize our Pinoccio board, and also initialize some global variables
Next we're gonna start the board and reading the values from the push buttons and the joystick.