Introduction: Your Own Smart Car & Beyond HyperDuino+R V3.5R With Funduino/Arduino
This is a direct copy from this set of instructions HERE. For more information head to HyperDuino.com.
With the HyperDuino+R v4.0R you can begin a path of exploration in many different directions, from controlling motors to exploring electronics, from programming (coding) to understanding how the physical and digital worlds can interact. With everything new that you learn, your own possibilities for invention, innovation and further discoveries are amplified ten-fold and more.
This particular tutorial takes the path of turning a cardboard box plus some wheels and motors into a “smart car”. This is often called robotics, but it’s a worthy topic of consideration as to just what differentiates an automaton (automata), smart cars and a “robot” (see also, origin of the word “robot”). For example, is this “tumbling robot” really a “robot”, or simply an automaton?
It might seem that the words are unimportant, however for our purposes, we consider the differences to be that an automaton is something that does not change its behavior based on an outside input. It repeats the same course of programmed actions over and over again. A robot is something which performs different actions in response to different inputs. In advanced form, the levels of multiple inputs can result in different actions. That is, not just one output per input, but different actions based on a programmed analysis of multiple inputs.
The “smart car” explores this range. In the simplest form, a smart car is pre-programmed to move in a pre-defined path. The challenge in this case might be to move the car through a pre-made “maze”. However, at that point, the success of the mission is determined totally by the pre-programmed set of actions, for example, forward 10, right, forward 5, left, etc.
In the next level, an input such as that from a range sensor can prompt the car to stop before it contacts that obstacle, and do a turn to take a new direction. This would be an example of one input, one action. That is, the same input (an obstacle) always results in the same output (a turn away from the obstacle).
At a more advanced level, the program may monitor multiple inputs, such as battery level along with path-following and/or obstacle avoidance, and combine all of these into an optimal next action.
In the first case, the program is just a sequence of moves. In the 2nd and 3rd examples, the program includes an “if-then” structure that allows it to do different parts of the program in response to inputs from sensors.
Step 1: Materials
HyperDuino box or similar
HyperDuino+R v3.5R + Funduino/Arduino
Transparent adhesive backed film (OL175WJ) with printed pattern. (or use this guide for just the motors & caster that can be printed on paper)
4-AA Battery box plus 4 AA batteries
2 reduction geared motors
2 wheels
1 roller ball caster
4 #4 x 40 1 ½” machine screws with #4s washer & nut
2 #4 x 40 ⅜” machine screws with #4s washer & nut
1 philipps/flat screwdriver
1 HC SR-04 Ultrasonic range sensor
1 9g servo
1 4xAA battery box
4 AA batteries
1 9v battery
1 IR remote control & IR receiver
1 SH-HC-08 bluetooth 4.0 BLE receiver module
1HC-SR04 ultrasonic sensor
2 3-wire connecting cables.
2 Grove-compatible 4-wire connecting cables.
1 Grove connector to sockets cable
1 blank white adhesive label
1 HyperDuino screwdriver (or similar)
Step 2: Constructing the Smart Car
(All Pictures Provided Above)
Prepare the Box
Although the HyperDuino Robotics kit could have included a plastic base called a “chassis” (pronounced “chass-ee”), we think it is much more satisfying to be as close to the “from scratch” construction of your smart car as possible. For that reason, we’ll start by re-using the cardboard box of the HyperDuino Robotics kit itself.
In the HyperDuino+R box, you’ll find an adhesive-backed piece of white paper, and an adhesive-backed piece of transparent material with outlines showing the positions for the HyperDuino, battery box, and motors.
There are also circles indicating where to place the adhesive-backed velcro circles.
1. Remove the adhesive backing to the white paper label, and place it over the HyperDuino label on the top of the box.Note: this adhesive pattern is provided to give a layout guide for a specific box, the MakerBit cardboard box. Once you have used that box up, or if you wish to use a different box, you can use this pdf pattern file intended to be printed on paper, and then cut out the motor guides (top and bottom = left and right) and one of the caster wheel guides. You can tape the paper in place while you make the holes, then once they’re made remove the paper pattern.
2. Unfold the HyperDuino+R box so that it can lay flat. This is probably the most difficult part of the project. You’ll need to sort of press-and-lift the tabs at each side of the box out of the slots on the bottom of the box. You may find that using the HyperDuino screwdriver to push from inside of the flap in an outward direction will help free the flaps.
3. Remove the half of the adhesive backing to the transparent material on the left side (if the HyperDuino logo is “up”), and place it inside the HyperDuino box with the half-outlines of the slots matching the cut-outs on the box. Do the best you can to line up the two horizontal lines with the folds of the bottom of the HyperDuino+R box.
4. After positioning the left side of the transparent film, remove the paper backing from the right half and finish attaching the pattern.
5. Use the phillips tip of the HyperDuino screwdriver included in your kit to make small holes for the machine screws that will hold the motors in place. There are two holes for each motor, plus a hole for the axle of the motor.
6. Continue and make two more holes for the roller ball.
7. For the axles of the motors, use the blue plastic hole-making tool of the HyperDuino kit to make the first small hole that aligns with the axles of the motors. Then use a plastic ballpoint pen or similar to enlarge the hole to about ¼” inch in diameter.
8. Put a washer on each of the long (1 ½”) machine screws, and push through the holes for the motors from the outside of the box. (It make take a bit of firm pressure, but the screws should fit through the holes snugly.)
9. Fit the motor, which has 2 small holes that match the machine screws, onto the screws and secure in place with the nuts. The HyperDuino screwdriver will be helpful in tightening the screws, but don’t overtighten to the point that the cardboard is crushed.
10. Repeat for the other motor.
11. Locate the velcro circles. Pair the hook and loop (fuzzy) circles together with the backing still attached. Then remove the backing from the loop (fuzzy) circle and attach each circle where you see the 3 outlines each for the HyperDuino board and the battery box. After placing, remove the backing from the hook circle.
12. Now carefully place the HyperDuino with its foam backing, and the battery box (closed and with the switch side “up”) onto the velcro circles. Press them down with enough force that they stick to the adhesive backs of the circles.
13. You can now attach the battery and motor wires. If you look very closely, you can see labels next to each of the 8 motor terminals, labeled A01, A02, B01 and B02. Attach the black wire of the upper motor (“B”) to B02, and the red wire to B01. For the lower motor (“A”), attach the red wire of the lower motor (“A”) to A02, and the black wire to A01. To make the connection, you gently insert the wire into the hole until you feel it stop, and then lift the orange lever and hold it open while you push the wire another 2mm or so further into the hole. Then release the lever. If the wire is properly secured, it will not come out when you give it a gentle tug.
14. For the battery wires, attach the red wire to Vm of the motor power connector, and the black wire to Gnd. Small motors can be powered from the Arduino 9v battery, but an additional battery like the four AA battery pack, can be used to power motors, and is connected using the 2 terminals at the upper-left of the HyperDuino+R board. The choice is up to you for your particular application, and is configured by moving the “jumper” to one position or the other. The default position is on the right, to power the motors from the 9v battery. For these activities, where you have added the four AA-battery case, you will want to move the jumper to the “left” position.
15. Finally fold the box all together as shown in one of the last remaining pictures.
16. Now is a good time to insert the two ⅜” machine screws with washers from the inside of the box through the holes, and attach the roller ball assembly with washers.
17. Now attach the wheels by just pressing them onto the axles. Pay attention to the wheels on the motor axels, so that the wheels are nicely perpendicular to the axles, and not angled any more than you can avoid. Well-aligned wheels will give the car a straighter track when it moves forward.
18. The last thing to do for now is to make a hole for the USB cable. This is not so easy to do in a pretty way, but with a little determination, you’ll be able to get the job done.Look at the USB connector on the HyperDuino board and the outlined box labeled “USB cable”. Follow that visually to the side of the box, and use the HyperDuino screwdriver phillips tip to make a hole that is about 1” above the bottom of the box, and as best aligned to the center of the USB cable path as you possible can. If this is off-center, it will make it a little more difficult later to connect the USB cable through the hole.After starting the hole with the screwdriver, enlarge it further with the blue hole-making tool, then a plastic pen barrel, and finally move up to a Sharpie or whatever other largest diameter tool you can find. If you have an Xacto knife, this will be best, but they may not be available in classroom settings.
19. Test the size of the hole with the square connector end of the HyperDuino USB cable. The hole won’t be very pretty, but you’ll need to make it large enough for the square connector to be able to pass through. Note: After making the hole, correctional fluid (‘White-out”) is one way of painting over the darker cardboard exposed by the hole-making.
20. To get the lid of the box to close, you’ll need to make 2 cuts with scissors where the flap would otherwise run into the motor, and either fold the resulting flap back a little, or cut it off entirely.
Step 3: Coding a Simple "Maze-Running" Program
The first programming challenge will be to create a program that can “drive” the car through a pattern.
To do this, you will have to learn how to use the iForge block programming language to create functions that will control the motors in unison to move forward and backward, and also make left- and right-hand turns. The distance moved by the car in each portion of its journey is determined by how long the motors run for, and at what speed, so you’ll learn how to control those as well.
In the interest of efficiency in this tutorial, we’ll now direct you to the “Coding with the HyperDuino & iForge” document.
That will show you how to install the iForge extension for Chrome, create an account, and build block programs that control pins on the HyperDuino.
When you have finished that, return here, and continue with this tutorial, and learning how to control motors using the HyperDuino.
Step 4: Basic Motor Control
At the top of the HyperDuino “R” board are easy-connect terminals that allow you to insert a bare wire from a motor or battery. This is so that no special connectors are required, and you’re more likely to be able to hook up batteries and motors “out of the box”.
Important Note: The names “A01” and “A02” for the motor connectors do NOT signify that the analog pins A01 and A02 control them. The “A” and “B” are only used to designate motors “A” and “B”. Digital I/O pins 3 through 9 are used to control any motors attached to the HyperDuino+R board terminals.
The battery should be chosen with a power capacity (milliamp-hours) and voltage appropriate to the motors that you are using. 4 or 6 AA batteries in a box such as this are typical:
Example from Amazon: 6 AA Battery Holder With 2.1mm x 5.5mm Connector 9V Output (Picture 2)
It is important to properly connect the polarity (positive & negative) to the Vm (positive) and Gnd (“ground” = negative). If you connect the positive lead of a power source to the negative (Gnd) input of the external power connection, there is a protective diode that blocks the short circuit, and at the same time, the motors will not energize.
The motor controller can control either:
Four single-direction DC motors connected to A01/Gnd, A02/Gnd, B01/Gnd, B02/Gnd
Note: only one “A” motor and one “B” motor can be on at the same time. It is not possible to have all four single-direction motors on at the same time.
Pin 8: high, Pin 9: low = Motor A01 “on”
Pin 8: low, Pin 9: high = Motor A02 “on”
(Pins 8, 9: low = both B motors off)
Pin 12: low, Pin 13: high = Motor B01 “on”
Pin 12: high, Pin 13: low = Motor B02 “on”
(Pins 12, 13: low = both B motors off)
Two bi-directional DC motors connected to A01/A02 and B01/B02
Pin 8 = high, pin 9 = low = Motor A “forward*”
Pin 8 = low, pin 9 = high = Motor A “reverse*”
(Pin 8 = low, pin 9 = low = Motor A “off”)
Pin 12 = high, pin 13 = low = Motor B “forward*”
Pin 12 = low, pin 13 = high = Motor B “reverse*”
(Pin 12 = low, pin 13 = low = Motor B “off”)
(*subject to polarity of motor wiring and orientation of the motor, wheel and robotic car.)
One stepper motor connected to A01/A02/B01/B02 and Gnd
The voltage and current limits of the HyperDuino motor controller are 15v and 1.2 A(average)/3.2 A (peak) based on the Toshiba TB6612FNG motor controller IC.
Motor “A”: Connect to A01 & A02
(Look at last two pictures for demonstration)
Motor Speed
The speed of motors A and B are controlled with pins 10 and 11, respectively:
Speed of Motor A: Pin 10 = PWM 0-255 (or set pin 10 = HIGH)
Speed of Motor B: Pin 11 = PWM 0-255 (or set pin 11 = HIGH)
In single-direction operation (four motors), the speed control of pin 10 operates for both “A” motors, and pin 11 for both “B” motors. It is not possible to independently control the speed of all four motors.
Low-Power Motors (less than 400ma)
The motor controller can use an external battery source of up to 15v and 1.5 amps (2.5 amps momentarily). However, if you’re using a motor that can run on 5-9v, and uses less than 400ma, you can use the black jumper next to the motor power connectors, and move it to the “Vin” position. The alternate position, “+VM” is for external power.
Smart Car Activity
With your smart car assembled, you can now proceed to the Smart Car Activity where you will learn how to program your car.