It consists of an arduino uno R3, a PP3 9v battery and a n old radio controlled car servo
The arm is an old Radio controlled car prop shaft but a wooden dowel would work also. It has a croc clip to attach to the mouse cable in order to move it forward and back
Here's a GIF of it in action!
See below for the code I used:
It is very simple wiring. The output of your servo goes to Pin 9 of the Arduino board.
The other wires of the servo go to power so i powered them directly from the Arduino board, be careful doing this in case your servo draws too much current, you may need an external power supply.
I also wired an LED directly to the 5v power output of the arduino so that I know when it is switched on.
Arduino Code:
/* Sweep
by BARRAGAN <http://barraganstudio.com>
This example code is in the public domain.
modified 8 Nov 2013
by Scott Fitzgerald
http://www.arduino.cc/en/Tutorial/Sweep
*/
#include <Servo.h>
Servo myservo; // create servo object to control a servo
// twelve servo objects can be created on most boards
int pos = 0; // variable to store the servo position
void setup() {
myservo.attach(9); // attaches the servo on pin 9 to the servo object
}
void loop() {delay(1000); //repeat every 10 seconds...
for (pos = 40; pos <= 140; pos += 1) { // goes from 40 degrees to 140 degrees
// in steps of 1 degree
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(20); // waits 20ms for the servo to reach the position
}
for (pos = 140; pos >= 40; pos -= 1) { // goes from 140 degrees to 40 degrees
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(20); // waits 20ms for the servo to reach the position
}
}