Robotics Learning Materials
Warning: These instructions are all "wrong". They work, but as a group we have changed the wiring and associated program code settings. This month (September 2019), updates should be posted.
During CoderDojo Saint Paul Event 00000010, ten groups of Ninjas, Parents, and Mentors worked side-by-side building Robocars.
Everyone soon discovered that there are multiple ways that the parts could go together (and assembly is not as simple as LEGO).
The Robocar kit from Amazon cost about $23. https://smile.amazon.com/dp/B01CXVA6IO/
The motor driver that the kit comes with is perfectly good to use. We happened to have 10 of the lower-profile L293D motor driver, purchased at about $1.5 each from a seller in China, via eBay. It is not necessary to switch to using the L293D motor driver.
The Dallas Personal Robotics Group (DPRG) posted a video, demonstrating one way to build this same kit. The plug of the kit in that video differs a little.
Following are the Build Steps Notes, Photos, and Test Code from the build completed by Leonidas and Bruce.
Tools Used: Small Screwdrivers, Wire Cutter, Wire Stripper (see notes below)
Original Build Steps
Note: This original build did not last long, as it had two issues:
1. In the code, the Servo library used disables PWM on Pins 9 and 10, which were used for one of the motors. Oops. 2. On some floor surfaces, the caster did not quickly change direction between forward and reverse, with the weight of the batteries over it.
- Mounted Motors and Switch on Bottom, with Motor Wires aligned on inside, towards Rear.
- Mounted Caster on Bottom at Rear, using two short Standoffs and four short Bolts.
- Mounted Arduino Uno using two short Standoffs and four short Bolts.
- Note: Header on Arduino initially obstructed flush/complete inserting of Bolt. Did not force it into place.
- Attached wires to Motor Driver VCC, GND, IN1, IN2, IN3, and IN4. We eventually bent all of these pins (forwards, as mounted), to lower the profile, allowing for more ground clearance.
- Mounted Motor Driver to Bottom of platform, between Caster base and platform, using two holes in platform where Castor could have attached.
- Attached wires to power side of Motor Driver:
- A-, A+ to Right Motor
- B-, B+ to Left Motor
- GND, VCC to Male-to-Male wires (see notes below). The GND will attach to Battery Negative, and VCC will attach to Switch.
- Attached Sensor Shield atop Arduino Uno. Careful when inserting, as the Arduino is supported at only two points. Press the Shield pins fully into the Arduino Headers.
- Mounted Servo at front, to underside of platform.
- Attached wires to Ultrasonic Sensor.
- Attached Battery Holder with just one Bolt and Nut.
- Unused Parts saved for future use.
- At Sensor Shield, attached Motor Driver control wires to Pins 5, 6, 9, 10 -- all are PWM Pins. Any 5V and G Pins work for VCC and GND connections.
- At Sensor Shield, attached Ultrasonic Sensor Echo and Trigger control wires to Analog Pins A4 and A5. Any 5V and G Pins work for VCC and GND connections.
- At Sensor Shield, attached Servo control wire to Pin 2. Note: Servo needs PWM for full usability. Any 5V and G Pins work for VCC and GND connections.
- Changed power wiring such that Red V+ from Battery Pack is attached to one side of Switch. Other side of Switch is connected to power input of plug at Arduino, and VIN at Motor Driver. This change included cutting and leaving disconnected one of the red wires at the power input plug for the Arduino.
The Disc that came with the kit likely has useful information, like diagrams, videos, photos, example code, and instructions, but we have not looked at its contents yet. (Our primary computer does not have an optical disc drive.)
Notes: The kit did not come with any Male-to-Male wires. These were cut from an old electronic toy that no longer worked. This is what the Wire Cutter and Stripper tools were used for.
Updated Build Changes
Includes changes for Motor Driver Wiring and Center of Mass (Batteries Location).
- Moved positions of Arduino and Battery Pack, such that Center of Mass is closer to drive wheels, away from pivoting caster.
- On the Motor Driver, removed jumpers from EN1 and EN2, connected two more wires to EN1 and EN2, and bent Pins down to increase ground clearance. Note: The wire on the VCC Pin (next to the black wire) appears light gray, but it is white on the opposite side.
- On the Sensor Shield, the wiring for the Motor Driver is in the photos, and described in the code example.
- On the Sensor Shield, the white wire from the Motor Driver VCC Pin was intentionally left disconnected, because the Motor Driver logic circuitry shares power from the Motor VIN connection (which was unexpected and unwanted and I could not figure out how to disable this -- I wanted all of the power to go to the motors).
- On the Sensor Shield, the PWM Pins were marked red, for easier identification.
- On the Sensor Shield, the Ultrasonic Sensor wires were connected to URF01, which uses Pins A0 and A1.
- On the Sensor Shield, the yellow Power SEL jumper was disconnected, to not share power with the V Pins in the Digital Pins Block. Maybe this keeps more voltage available to the motors -- I do not know and did not measure it.
- Across the bottom in the photo of all Sensor Shield wiring, note the three exposed Pigtails.
- The Pigtail on the left with two red wires connects V+ Battery output to one side of the Switch.
- The Pigtail in the middle with three red wires connects the other side of the Switch to the Power of the round Plug into the Arduino, and to VIN of the Motor Driver.
- The Pigtail on the right connects GND of Motor Driver to Ground of the round Plug into the Arduino. The other Ground wire from the round Plug connects to V- of the Battery Pack.
Original Build Photos
Updated Build Photos
Following is a link to Arduino C code to compile and upload with a tool like Arduino IDE.
At future events, we will learn more about using mBlock to write and deploy code to our robots. mBlock uses blocks, like the Scratch coding environment, which is especially great for kids who are not yet ready for typing.
Warning on the Servo
I tried to use the servos to swivel the ping sensor and I had several findings:
- The servos are not very reliable. I had several that didn't work well out of the box or after moderate use.
- The plastic gears in the servo are very easy to strip. The kids stripped 1/2 of them in the first event.
- Most kids didn't understand the code needed to look right, look forward, look left and compare the distances.
My advise is to keep the initial labs simple and just use a fixed ping sensor. If the kids get that mastered with the turning logic then add the servo.