Mouse motor control
The Idea
During this week we developed a circuit which involved connecting a servo motor to an Arduino Nano 33 iot. This week’s project consisted of developing something which I had started working on last week, to control something physical with some king of haptic or visual interaction through human input.
The Video
The Process
The system consists of using a mouse to control the position of a Servo motor (ref. HS-311). . For dealing with the mouse interaction, I used p5 to send the mouse’s position to Arduino, which translated this value into an angle the servo motor could move. I used serial communication to create a bridge between both software and send the values of the mouse’s position in the Y axis to the Arduino.

The connection between the servo motor and the Arduino was straightforward. The servo motor three female headers, one for power, one for GND and another for communicating with the arduino.

I wanted to make some kind of visual feedback on the screen, as well as to debug my serial connection. So I made a bullseye that tracks mouse movement, maps the value between 0 – 179, and sends the mapped value to the Arduino as a serial message. Since this had to be updated in real time, and since p5 and Arduino both communicate in an asynchronous manner at a 9600 baudrate, I would send this updated value every loop.


As seen on the image above, I am sending a value and receiving the angle in which the motor has rotated the object attached to it.
The Code


Arduino Code Repository : https://github.com/lacouture100/Intro-to-Physical-Computation-ITP/tree/master/Week_3/Arduino%20Code
P5 Code Repository : https://github.com/lacouture100/Intro-to-Physical-Computation-ITP/tree/master/Week_4/p5_code
Thanks for reading!