RoboDragon
This is to be (aka not done yet) an animatronic dragon's head. It currently has 3 PIR sensors to act as eyes. My goal is to have it interact on some limited level with people. The idea is to have to head turn right/left towards the most recent movement, and center itself on the 'target' and perform some other entertainment behaviors (open mouth, blink lights, etc..) So far I can get it to turn towards movement on it's right, but I seem to have a problem with the code to turn the other direction. I know the sense routine is working (I've checked the output), but the movement routine has a problem I was hoping someone on LMR can give me a hint to get me back on track. Yes, this is my first 'robot'.. I have no plans to leave the microcontroller imbeded, so I'm using an Arduino. Here's the function I'm having problems with...
void moveHeadNeck() {
int alittle = 1; // a small move to one side for fine tuning
int alot = 2; // a big move to one side when something new is noticed.
int cPos = neck.read(); // current position of neck servo
// Serial.print("cPos:"); Serial.println(cPos);
// Serial.print("cPos-1:"); Serial.println(cPos-1);
if (motionCenter==true) {
if (motionRight==true) {
// move a little to the right
neck.write(cPos-alittle);
Serial.println("Motion to the CENTER/RIGHT");
}
if (motionLeft==true) {
// move a little to the left
neck.write(cPos+alittle);
Serial.println("Motion to the CENTER/LEFT");
}
} else { // motionCenter==false
if (motionRight==true) {
// move a lot to the right
neck.write(cPos-alot);
Serial.println("Motion to the RIGHT");
}
if (motionRight==true) {
// move a lot to the left
neck.write(cPos+alot);
Serial.println("Motion to the LEFT");
}
}
}
This moves to the right (adding) just fine, but refused to turn to the left (subtracting). Any suggestions?
Turn towards detected movement
- Actuators / output devices: Servos, LEDs
- Control method: autonomous with manual control over-ride options
- CPU: Arduino
- Power source: 5.6v via 4 rechargable AA batteries.
- Sensors / input devices: PIR
- Target environment: Outdoors