Overview
Not really an audio project, but still fun. The entire purpose of this project was to make a silly cat toy.
It uses a joystick to control two sg90 servos to move around a laser pointer. This is actually a pretty easy project to setup. The joystick is essentially just two potentiometers, one controls the x axis servo, the other controls the y axis. All you need to do is read the analog values from each of the potentiometers, and use the Arduino map() function to map them to the angles of the servos.
It uses a joystick to control two sg90 servos to move around a laser pointer. This is actually a pretty easy project to setup. The joystick is essentially just two potentiometers, one controls the x axis servo, the other controls the y axis. All you need to do is read the analog values from each of the potentiometers, and use the Arduino map() function to map them to the angles of the servos.
This has two modes, on where you control the servos with the joystick, and another where the laser randomly moves around. For the random mode, I thought that just mapping random values directly to the servos would make it too erratic. Instead of implementing the random mapping in that way, I made an array of coordinates. This array essentially broke the throw of the laser into a 3x3 grid. Then different positions are randomly chosen from this array, and the laser is set to the chosen positions.
There were a couple of other features I added, a play/pause button for the random mode, a speed control, which controls how fast the laser moves in the random mode, and also a button which controls the width of the throw of the laser.
There were a couple of other features I added, a play/pause button for the random mode, a speed control, which controls how fast the laser moves in the random mode, and also a button which controls the width of the throw of the laser.
Code
Full repository : https://github.com/zacrogers/ServoJoystick
Comments
Post a Comment