a small felt version of myself that turns its head and looks at you.
This is a project on using 123D Catch to get a 3D scan of my whole body. Once I had the scan I cleaned it up and manipulated it ready for 123D Make. I sliced the model in Make and preped it for Laser cutting. Once done I lazer cut and integrated the componentry and Arduino to make the head turn. I created two functions an automatic tracking function and a manually controlled function through Max MSP. In a way this is a Modern Day Puppet.
Code below the jump:
[sourcecode language=”css”]
/*
Simple Pan Tracking with 2 IR Sensors
Requires Arduino IDE version 0017
or later (0019 or later preferred)
*/
#include <Servo.h>
Servo servo; // Define the servo
const int lineLSense = A4; //Define the Left IR Sensor
const int lineRSense = A2; //Define the Right IR Sensor
int degree = 90; //Starting point of the Servo
int irReflectR = 0;
int irReflectL = 0;
int thresh = 200; //You can adjust this threshold to manipulate the range of your IR sensor readings.
void setup() {
servo.attach(9); // servo pin D9
Serial.begin(9200);
}
void loop() {
// Read reflective sensors
int trav = 2;
irReflectL = analogRead(lineLSense);
irReflectR = analogRead(lineRSense);
if (degree >= 180){
degree = 179;
}
if (degree <= 0){ degree = 1; } if (irReflectL >= thresh && irReflectR >= thresh) {
Serial.println("on line");
}
if (irReflectL >= thresh && irReflectR <= thresh) {
servo.write(degree + trav); // veering off right
degree=(degree + trav);
delay(4);
Serial.println("veering off right");
}
if (irReflectL <= thresh && irReflectR >= thresh) {
servo.write(degree – trav); // veering off left
degree=(degree – trav);
delay(4);
Serial.println("veering off left");
}
// If line is lost try to reacquire
if (irReflectL < thresh && irReflectR < thresh) {
Serial.println("lost");
delay(20);
}
}
// Motion routines for line following
void line_forward() {
servo.write(0);
}
void line_slipRight() {
servo.write(degree + 5);
}
void line_slipLeft() {
servo.write(0);
}
void line_spinRight() {
servo.write(180);
}
void line_spinLeft() {
servo.write(0);
}
[/sourcecode]