Mikey Go Home

by MikeTheMaker in Circuits > Robots

4177 Views, 31 Favorites, 0 Comments

Mikey Go Home

charge11.jpg

Mikey, the robot with vision

https://www.instructables.com/id/Mikey-the-Robot-wi...

can now see how to go home to his charger.

charge05.jpg

To build a charging station, I used a 6" x 18" piece of aluminum, 6" of 1/4" diameter aluminum rod, three 1/4" x 2 1/2" x .016" springs, two 7/16" x 8 1/2" x .047" springs, a 9 volt dc power supply, 2" wide aluminum duct tape (16 inches) and misc. connectors and hardware.

Add tape to the bottom of the robot.

charge06.jpg
charge07.jpg

Create a connector to attach to the tape. Note that the tape only conducts on the non-sticky side, therefore each piece of tape must be electrically connected to the circuit.

charge01.jpg
charge02.jpg

3D design files are here:

http://www.thingiverse.com/thing:335442

Drill holes in the rod and press fit the rods into the holders.

charge08.jpg

Attach the brackets to the robot.

schemwithcharger18052014.jpg
charge10.jpg

Wire the robot as shown in the schematic. I used a prototype board to make connections more easily.

charge04.jpg
charge09.jpg

Add the spring holder (3D printed) and springs. Attach the two springs in the center by soldering bare copper wire between them. Drill holes three inches apart (slightly smaller than the spring) and place the small springs (cut into 1 1/4" pieces) into the holes. Attach the dc power supply, positive to the upper springs and negative to the base plate.

Code

Load the code below into the Arduino that controls the motors.

int charge=0; int val=0; int val1=0; int valm=0; int valm1=0; int jump=3; int ctr=0;//counter const int pwmA=3; const int pwmB=11; const int brakeA=9; const int brakeB=8; const int dirA=12; const int dirB=13; const int right=5; const int left=7; const int chglt=6; void setup() { pinMode(dirA, OUTPUT); pinMode(brakeA, OUTPUT); pinMode(dirB, OUTPUT); pinMode(brakeB, OUTPUT); pinMode(right,INPUT); pinMode(left,INPUT); pinMode(chglt,OUTPUT); digitalWrite(dirA, HIGH);//forward A digitalWrite(brakeA,LOW);//release brakeA analogWrite(pwmA,100);//set speed A digitalWrite(chglt,HIGH);//test charge light digitalWrite(dirB,HIGH);//forward B motor digitalWrite(brakeB,LOW);// analogWrite(pwmB,100);//set speed B delay(700); digitalWrite(chglt,LOW);//set charge light off } void loop () { if (jump==0) { analogWrite(pwmA,0);//charge found analogWrite(pwmB,0); digitalWrite(chglt,HIGH); delay(50000); } if (jump==1) { valm=analogRead(0); valm1=analogRead(1); if(valm>500 or valm1>500) { valm=analogRead(0); valm1=analogRead(1); if(valm>450 or valm1>450) { digitalWrite(brakeA, HIGH); digitalWrite(brakeB, HIGH); digitalWrite(dirA, LOW);//reverse A digitalWrite(brakeA, LOW);// analogWrite(pwmA, 200); digitalWrite(dirB,LOW); digitalWrite(brakeB,LOW); analogWrite(pwmB,200); delay(700);//backup digitalWrite(brakeA,HIGH);//stop one wheel analogWrite(pwmA,0); delay(1000); digitalWrite(brakeB,HIGH);//stop other wheel //start both wheels forward digitalWrite(dirA,HIGH); digitalWrite(brakeA,LOW); analogWrite(pwmA,140); digitalWrite(dirB,HIGH); digitalWrite(brakeB,LOW); analogWrite(pwmB,140); delay(1000); }}} //find station if (jump==3) { analogWrite(pwmA,0); analogWrite(pwmB,0); val=digitalRead(right); val1=digitalRead(left); if (val==HIGH && val1==HIGH) { analogWrite(pwmA,140); analogWrite(pwmB,140); if (ctr<150) { ctr=ctr+1; charge=analogRead(2);//test for charge station if(charge>100) { jump=0; ctr=5000; } if(ctr==150) { ctr=0; }} } if (val==HIGH &&val1==LOW) { analogWrite(pwmA, 190); analogWrite(pwmB,50); if (ctr<150) { ctr=ctr+1; charge=analogRead(2);//test for charge station if(charge>100) { jump=0; ctr=5000; } if(ctr==150) { ctr=0; }} } if (val1==HIGH && val==LOW) { analogWrite(pwmB,190); analogWrite(pwmA,50); if (ctr<150) { ctr=ctr+1; charge=analogRead(2);//test for charge station if(charge>100) { jump=0; ctr=5000; } if(ctr==150) { ctr=0; }} } }}

charge03.jpg

Place the target color in the center of the springs and power the robot on. It should seek the home base and stop when it arrives.

Future additions will make the robot leave the base, run around for a while, then return.

Mikey Go Home