Phone Controlled Robot With LinkitONE
by ssarthak598 in Circuits > Arduino
928 Views, 5 Favorites, 0 Comments
Phone Controlled Robot With LinkitONE
Ever wondered how robots are made? Wanted to make a cool project? Got a Linkit board? Then you are at the right place!
Here i'll be making a robot with LinkitONE with some local robotic parts and servo motors.
Lets begin..
What Do You Need?
Electronics:
1) LinkitONE board
2) Battery pack
3) Breadboard
Robotic parts:
1) Axels
2) Gears
3) Wheels
3) Sliders
4) Metal board
5) Plastic shelters
6) Relay box
Building the Main Strcuture
Now we need to build the main structure. For this we'll use 2 main metal sheets and one half size sheet to attach the both. This will make a basic structure for balancing the robot.
Attaching the Servos
Now we'll attach some servo motors and then plug them up. Carefully attach them using holes and use more than 2 nuts and bolts to attach so it is not loose and can be tightened up.
After this, move to the next step.
Hooking Up Gears
Now we'll hook up some gears. We'll attach 2 gears together with one small gear in between like this. This will help us make a good maniacal design that gives more amount of tourge.
Attaching the Wheels
Now attach the wheels! Carefully attach them on the axle and tighten it up nicely so it doesn't come out. Do check twice that the wheels are in their proper position.
Adding a Breadboard
Now we can also interface sensors, for that add a breadboard to it. Add it under the robot so its not visible!
Connecting the Motors
Finally connect the motors together and connect the wires to the relay box.
Attaching the Relay Box With Linkit
This comes the main part. You'll need to interface Linkit board with your relay bx as the relay box has batteries and motor ICs. Interface that using the servo library.
Pin connections:
SN1 - Pin 13
SN2 - Pin 12
SN1 - Pin 11
VCC - VCC of your board
GND - GND of your board
After this you are done! Now we'll program the robot and get started with the code.
Finalizing the Robot Design!
Finalize the design by attaching the relay box correctly and tightening up everything.
Writing Some Code
Now we are going to write some code.
See the code from the web-led.ino file and burn the code.
The code is simple, when ever it finds a client, it gives back a webpage where you can control it!
CODE
-------------
#define WIFI_AP "Your WiFi network" // chance this to your wifi network name #define WIFI_PASSWORD "Password" // change this to the password for the network #define WIFI_AUTH LWIFI_WPA // choose from LWIFI_OPEN, LWIFI_WPA, or LWIFI_WEP according to your WiFi AP configuration // If this doesn't work, try LWIFI_WEP. If your network doesn't have a password, use LWIFI_OPEN. int serverPort = 80; LWiFiServer server(serverPort); int LED = 13;
void setup() { pinMode(LED, OUTPUT); LWiFi.begin(); Serial.begin(115200); // keep retrying until connected to AP Serial.println("Connecting to AP"); while (0 == LWiFi.connect(WIFI_AP, LWiFiLoginInfo(WIFI_AUTH, WIFI_PASSWORD))) { digitalWrite(LED, HIGH); delay(100); digitalWrite(LED, LOW); delay(100); digitalWrite(LED, HIGH); delay(100); digitalWrite(LED, LOW); delay(600);
} digitalWrite(LED, HIGH); printWifiStatus(); Serial.println("Start Server"); server.begin(); Serial.println("Server Started"); digitalWrite(LED, LOW); }
int loopCount = 0;
void loop() { // put your main code here, to run repeatedly: String str = ""; String url = ""; int i; delay(500); loopCount++; LWiFiClient client = server.available(); if (client) { Serial.println("new client"); // an http request ends with a blank line boolean currentLineIsBlank = true; while (client.connected()) { if (client.available()) { // we basically ignores client request, but wait for HTTP request end char c = client.read(); Serial.print(c); if(c != '\n') str += c; if(c == '\n') { //Serial.println(str); if(str.startsWith("GET ")) { url = str.substring(4, str.lastIndexOf(" ")); Serial.print("URL:"); Serial.print(url); Serial.println(":"); } str = ""; }
if (c == '\n' && currentLineIsBlank) { Serial.println("send response"); // send a standard http response header client.println("HTTP/1.1 200 OK"); client.println("Content-Type: text/html"); client.println("Connection: close"); // the connection will be closed after completion of the response client.println();
if(url != String("favicon.ico")) { client.println("");
//i = digitalRead(LED); url.toLowerCase(); if(url == String("/on")) { digitalWrite(LED, HIGH); client.println("Turning LED on "); } else if(url == String("/off")) { digitalWrite(LED, LOW); client.println("Turning LED off "); } else { client.println("Doing nothing "); } client.println("
\n
"); client.println(); break; } } if (c == '\n') { // you're starting a new line currentLineIsBlank = true; } else if (c != '\r') { // you've gotten a character on the current line currentLineIsBlank = false; } } } // give the web browser time to receive the data delay(50);
// close the connection: Serial.println("close connection"); client.stop(); Serial.println("client disconnected"); } }
void printWifiStatus() { // print the SSID of the network you're attached to: Serial.print("SSID: "); Serial.println(LWiFi.SSID());
// print your WiFi shield's IP address: IPAddress ip = LWiFi.localIP(); Serial.print("IP Address: "); Serial.println(ip);
Serial.print("subnet mask: "); Serial.println(LWiFi.subnetMask());
Serial.print("gateway IP: "); Serial.println(LWiFi.gatewayIP());
// print the received signal strength: long rssi = LWiFi.RSSI(); Serial.print("signal strength (RSSI):"); Serial.print(rssi); Serial.println(" dBm"); }
-------------
Once you complete this step, go to the URL of LinkitONE and access your web interface.
http://192.168.xx.xx/on1 for turning motor 1 on
http://192.168.xx.xx/on2 for turning motor 2 on
Building an Android App (Optional)
I made an android app for controlling the robo. It's very easy to do so!
You just need to use App Inventor, and build a simple app using its web interface. There are a lot of tutorials on app inventor, so refer to them.
Finalizing the Circuit!
Now finalize the circuit by connecting the WiFi antenna and the battery. After doing this you are finally done to play with it!
Testing It Out!
Test it out! Build the app and then test it! When you press up button, it turns on and when you press down it turns off!