Started drawing in class
Planned diagram after class
I am not a computer science major and this is pretty much Greek. I knew that I wanted to make a monster that moved his head and wobbled at the same time. I did a google search for codes that could help me do this. I found a book called, “The Best of Make: Vol 2,” which had a whole chapter dedicated to servomotors. The book listed a few codes and I copied them with the intention of combining the different items into one giant code. However, I made a few errors.
One, I did not differentiate between servos. I wrote myservo and servoPan, but I did not specify which servo was meant to be servoPan in the upper portions of the code.
Ultimately, when I attempted to run the code, it did not work. I kept getting various error messages. I ended up deleting portions of the code after trying to troubleshoot by using the Arduino.cc FAQs. Then, I reached out to Duncan as I could not understand, after doing research, what was wrong. It ended up being an issue with the void setup and void loop.
Here are the codes I tried to use. The first one is using the Best of Make.
// Servo – Version: 1.1.5 #include <Servo.h> Servo myservo; // create servo object to control a servo
Servo servoPan; // servo to pan
void setup() { myservo.attach(10); // attaches the servo on pin 9 to the servo object
servoPan.attach(9); //pan servo is on pin 9
servoPan.write(90); // home both servos to center
myservo.attach(9); // servo is on pin 9
myservo.write(90); // set servo to 90 degree position
pinMode(servoPin; OUTPUT); }
void loop() {
for(pos = 90; pos >= 0; pos -= 2){ // goes from 0 degrees to 180 degrees // in steps of 2 degree
myservo.write(pos); // tell servo to go to position in variable ‘pos’
delay(20); // waits 15ms for the servo to reach the position }
for(pos = 90; pos >= 0; pos -= 2){ // goes from 0 degrees to 180 degrees
servoPan.write(pan); //move pan servo
myservo.write(servoPin, HIGH); // tell servo to go to position in variable ‘pos’
delay(15); // waits 15ms for the servo to reach the position
myservo.write(servoPin, LOW); } }
After I was having issues with the code. I decided to try to tweak the code from the Arduino library, the SWEEP and KNOB, and still ran into issues. This is because I was not thinking about the integer numbers. I chose an integer that would ensure that my robot would never run. I started at 0 and said as long as it was <=90, which zero is, the Arduino would not move because it fulfills the function of the code.
/*
Controlling a servo position using a potentiometer (variable resistor)
by Michal Rinott <http://people.interaction-ivrea.it/m.rinott>
modified on 8 Nov 2013
by Scott Fitzgerald
http://www.arduino.cc/en/Tutorial/Knob
*/
#include <Servo.h>
Servo myservo; // create servo object to control a servo
int potpin = 10; // analog pin used to connect the potentiometer
int val; // variable to read the value from the analog pin
int pos = 90; // variable to store the servo position
void setup() {
myservo.attach(9); // attaches the servo on pin 9 to the servo object
}
void loop() {
val = analogRead(potpin); // reads the value of the potentiometer (value between 0 and 1023)
val = map(val, 0, 1023, 0, 180); // scale it to use it with the servo (value between 0 and 180)
myservo.write(val); // sets the servo position according to the scaled value
delay(15); // waits for the servo to get there
}
void setup() {
myservo.attach(10); // attaches the servo on pin 9 to the servo object
}
void loop() {
for (pos = 0; pos <= 90; pos += 3) { // goes from 0 degrees to 180 degrees
// in steps of 3 degree
myservo.write(pos); // tell servo to go to position in variable ‘pos’
delay(20); // waits 15ms for the servo to reach the position
}
for (pos = 90; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
myservo.write(pos); // tell servo to go to position in variable ‘pos’
delay(20); // waits 15ms for the servo to reach the position
}
}
I used felt, feathers, Popsicle sticks, straws to create my pombot. I had stuffed a few of the pompons inside, but found I needed more because the felt provided no structure and thus, the pombot was too top-heavy. I did not stuff it enough at the end of the day, however, since I still had to hold the bot.
It was suggested that to get the robot to move the way I wanted, I needed a third servo. When I put the third servo to the pom bot, it would twitch and then, not move. Brandon tried to help me get it going, but we came to conclusion that I fried the motor with three. Therefore, I decided to keep it at two only.
Ultimately, my pombot does not wobble like I intended. It also pretty much walks by scooting. I thought the head also did not work the way I wanted. However, it does move, but I held it up since my pombot was too top heavy.
The final code with the three servos, but discovered that three-servos does not work for the robot because the third servo stops working immediately after being plugged.
Tried to get the third servo to work by plugging directly into the arduino rather than the breadboard
All of the servos plugged into the breadboard.
head moving
Servo on the back of the cloth. I moved the servo later because it did not really move the item.
My servo trying to move across the table, moved the bottom servo to a Popsicle stick on the bottom. I had to hold up the pombot because as aforementioned, it was still too top heavy.
In conclusion, if I were to do this over again, I would make a shorter monster, one that I did not need to hold. I would also maybe use two Arduinos since three servos was too much to handle.