This is an easy little project that I might actually keep around and use, unlike most of my other projects. It is kind of an electronic pantograph - copying a picture by tracing it then produces a facsimile copy - although the copy is quite rough, it looks fairly artistic and faithful to the original without being a duplicate.
It will be improved by using a longer arm to make a larger copy and by replacing the micro servos with standard size ones to produce a less wavy line
Quite fun and easy to use.
#include <Servo.h>
Servo arm,elbow;
int potPinArm = 1;
int potArmVal = 0;
int potPinElbow = 2;
int potElbowVal = 0;
void setup() {
Serial.begin(9600);
arm.attach(2);
elbow.attach(3);
}
void loop() {
potArmVal = analogRead(potPinArm);
Serial.print("potArm="); Serial.print(potArmVal);
potArmVal = map(potArmVal,0,700,179,0);
Serial.print("potArmVal="); Serial.print(potArmVal);
arm.write(potArmVal); // make the servo go to the pot position
delay(10);
potElbowVal = analogRead(potPinElbow);
Serial.print("potElbow="); Serial.println(potElbowVal);
potElbowVal = map(potElbowVal,0,700,179,0);
Serial.print("potElbowVal="); Serial.println(potElbowVal);
elbow.write(potElbowVal); // make the servo go to the pot position
delay(10);
}