Introduction: Make a Wi-Fi Controlled Robot Using LinkIt ONE
Here is a step by step guide which will help you build first robot and add complexity, as you follow along. In addition to building an basic obstacle avoiding robot using an UltraSonic sensor and Sparkfun motor driver , you will also learn how to build a Wi-Fi controlled robot using Mediatek LinkIt ONE board which has on board Wi-Fi as shown in the video above.
We will use the Arduino IDE to upload the code/sketches attached in the steps below. And as part of the 3rd sketch you will setup a tiny web server on the LinkIt ONE, to serve the controller App that you can use your Mobile/Tablet browser to invoke and control the robot.
Step 1: Components You'll Need
Here are the components you will need to complete the build
- Mediatek LinkIt ONE board, which is an Arduino board which had onboard Wi-Fi, GSM and GPS, this will act as the brain of your robot and will host the web server for the controller. - cost 59$
- Lipo battery - this comes with Mediateck LinkIt ONE package
- Sparkfun Motor Driver - Dual TB6612FNG (1A) - cost 9$ , and you will also need header to solder to the breakout board so that you can use
- For the robots chassis ActoBitty 2 by Actobotics , this is small,simple and easy to assemble.And the best part is that the chassis comes with snaps which you can snap any Arduino type board on it.In addition it also comes with motors and the required battery holder - cost 30$
- 4 AA batteries
- Ultrasonic sensor HC-SR04 for obstacle detection - cost - 4$
- Breadboarding wire
If you don't have the LinkIt ONE board handy you follow along till step 5 to build a simple obstacle avoiding robot using an Arduino Uno
For details on how to assemble the ActoBitty 2 robotic chassis ,watch the youtube video below by servo city.
Step 2: Putting the Circuit Together
After assembling the ActoBitty 2 robotics chassis stick the mini breadboard in the front of the board as shown in the first picture above.
Load up the battery holder with 4 AA batteries and add it to the back as shown in the picture above.
Now complete the connection between the LinkIt ONE and the Motor driver board on the breadboard
- STBY to pin 10 on the base shield which act as the Standby
To control left motor of the truck
- PWMA to pin 3 - this is a PWM pin to control the speed of the motor
- AIN1 to pin 7
- AIN2 to pin 8 - both these pins decide the direction the back wheels will spin.
To control the right motor which provides direction to the truck
- PWMB to pin 9 - this is the second PWM pin available on the LinkIt ONE
- BIN1 to pin 5
- BIN2 to pin 6
Complete the other side of the connections of the motor driver, to left and right terminal of the motors
- A01 to one terminal of the left motor
- A02 to the other terminal
- B01 to one terminal of the right motor
- B02 to the other terminal
Then to Power up the motor
- Connect VCC on motor driver to 5V on LinkIt ONE
- and VM on the motor driver to +ve of the battery holder
- GND which to the GND of the battery back and then to GND of the LinkIt ONE(this is also referred as a common ground)
Step 3: Uploading Code to Arduino - Running Basic Test
Now once you put the circuit it is time to download the code attached and upload it using the latest Arduino IDE.
To setup the Arduino IDE for the LinkIt ONE register, first create an account on the MediaTek Labs website
And then follow the link below to download the latest driver and software LinkOne Board
One you have successfully complete the setup you should see an option to select the board as LinkIt ONE as shown in the picture above.
Upload the blink example sketch that comes with the Arduino IDE and see if the LED on the LinkIt one board blink, this means you have completed the setup of the Arduino IDE sucessfully.
Now open the file you have downloaded and upload it to the LinkIt one by selecting the port you are connected on as shown in the picture above.
At this you may have to swap the connection A01 and A02 if your left motor is moving in the opposite direction of the right motor.
Connect the battery and place the robot on a flat surface and you should see you robot move around as shown in the video below
Step 4: Adding Ultrasonic Sensor to Make the Robot Avoid Obstacles
Now once you have got the basic movement down, you are now ready to make you robot autonomous using an Ultrasonic Sensor
Connect the HC-SR04 to the breadboard and the make the following connection
- Connect Echo pin on the ultrasonic sensor to pin #2 on the LinkIt One
- then connect the Trig pin to pin #4 on the ultrasonic sensor
- connect the GND pin to the common ground on the bread board
- connect the VCC to 5V of the LinkIt One
Step 5: Uploading Arduino Code - Testing the Autonomous Robot
Download the code attached and upload it to the LinkIt one using the Arduino IDE
With the robot place on the platform which in my case is the foam which came with the LinkIt ONE package change the port to the debugging port. The debugging is the other port which shows up under the Tools > Ports section and then click on the serial monitor to the right of the Arduino IDE.
As part of the code we have set obstacle detection threshold to 10 cms, to test that your robot stops and moves left place you hand or an object in front, and on your serial monitor you should see the obstacle detected as shown in the picture above.
At this point you may increase or decrease the obstacle detection threshold of 10 cms in the code.
Now comment out the Serial.begin line in the code and upload you code to LinkIt One and connect the Lipo battery as shown in the picture above.
Step 6: Adding the WiFi Antenna to the LinkIt ONE
Now to control the Robot over WiFi we need to attach the WiFi antenna to the LinkIt ONE.
Snap off the LinkIt one to attach the WiFi Antenna to the middle antenna slot as show in the picture above.
The WiFi antenna is part of the Link It ONE package.
Step 7: Download the Code and Change You Wifi Router Name and Password
Download the Arduino code attached and change the following in the code as shown in the picture above
- WIFI_AP value which is your Wi-Fi Router name
- WIFI _PASSWORD value which is the password for the WiFi router.
The second file attached is the CSS file linked as part of the Arduino Code, this file is uses to the web app controller buttons which gives them green color and makes large enough so that it is easy to press them.
I have temporarily hosted the css using rawgit.com via my github link.
Step 8: Uploading Wifi Controller Code
Now using the Arduino IDE upload the code attached to the LinkIt ONE board.
In the Serial Monitor change your baudrate to the value in the Serial.begin in the setup() section of the code, which in this case is 115200.
Using a web browser on you phone/tablet or laptop open the web server using the IP address assigned to your LinkIt ONE which you should see in your Serial Monitor, which in my case is http://192.168.0.16 as shown in the picture of the serial monitor above.
Once you are satisfied with the movement comment the Serial.begin line and upload the code.
Connect the Lipo battery to power on the robot.
Congratulations ! you are done if you are able to control the robot using the web serve app as show in the video below.