After a late night last night with a test assembly of my Tiny Mobile Robot I wasn't quite so chipper this morning as I usually am. Still, I did have time to think about how to connect everything together so it would fit inside the shell. I used a bit of stripboard to make connections for the two 360 degree continuous rotation servo motors and the HC-SR04 ultrasonic rangefinder, plus power. There were surprisingly few connections once I had removed it from the proto-plugin board to a small stripboard and then connected the Arduino Nano using Dupont inter-connection wires.
The connections are as follows (Arduino to peripheral)
D3 servo motor 1
D4 servo motor 2
D5 Echo signal for HC-SR04
D6 Trigger signal for HC-SR04
All the other connections are just ground and power. Only a few connections. One of my original possible ideas had been to use a ATtiny85 for the controller for this but this would have required creating a programmer using an Uno and in the end I decided this was a complication too far for 24 hours. Still, I will create my ATtiny85 programmer soon and then I might revisit this mobile robot.
Once I had done all this connecting I was able to stuff it all inside the bodyshell. Regretfully I haven't yet managed to fit the batteries inside (there is enough space inside for 4xAAA batteries although not in a normal holder - if there was a smaller Arduino and fewer wires). Also I wasn't able to fit the batteries and the HC-SR04 ultrasonic rangefinder, yet. I think it would only require a couple more hours to do this so I might have a good.
The programme is pretty simple at present, all it does is to take one distance reading from the ultrasonic rangefinder and then moves to a while loop that just runs the servo motors from maximum forward speed all the way to zero and then to maximum backwards speed. With a bit more time then a much better programme could be produced.
digitalWrite(ustrigger, LOW);
delayMicroseconds(pretriggerdelay);
duration = 0;
distance = 0;
digitalWrite(ustrigger, HIGH);
delayMicroseconds(trigdelay);
digitalWrite(ustrigger, LOW);
duration = pulseIn(usecho, HIGH);
distance = duration/onecmdelay; // Conver to centimetres
Serial.println(distance);
while(1)
{
for (leftspeed = start; leftspeed <= end; leftspeed++)
{
leftwheel.write(leftspeed);
rightwheel.write(180 - leftspeed);
delay(stepdelay);
} /* for */
for (leftspeed = end; leftspeed >= start; leftspeed--)
{
leftwheel.write(leftspeed);
rightwheel.write(180 - leftspeed);
delay(stepdelay);
} /* for */
} /* while */
Once put back together and the batteries added and turned on the Tiny24hourMobot springs into life. Well, maybe wombles about a bit anyway, see video below:
I did print a top to fit onto the body shell as well, but at present the wires get in the way so here it is without the batteries, or the wires or the HC-SR04 to show what it could have looked like. The first photograph shows the rather chaotic inside and the next one with the lid on showing a much more streamlined view.
I think this final photograph shows that if I could get it all to fit inside the shell I might have quite a nice looking mobile robot. I also think that with the experience
I now have I should be able to make it even smaller. The sensors need more thinking about though. The HC-SR04 is really too big so something much smaller is needed.
Dubbie
Top Comments