WiFi Robot




I have created the framework for WiFi and voice control of a robot. The MKR1000 chip enables us to receive controls over WiFi.

Things used in this project

Hardware components

Arduino MKR1000
Arduino MKR1000
× 1
DC motor (generic)
× 2
Wheels
× 1
Dual H-Bridge motor drivers L298
SparkFun Dual H-Bridge motor drivers L298
× 1
9V battery (generic)
9V battery (generic)
× 1

Story

Schematics

Code

WiFi Server

Arduino

This is a generic server that allows us to read data that clients send. Specifically, when I get a connection from the Joystick, it can take the inputs.
#include <SPI.h>
#include <WiFi101.h>

char ssid[] = "";       // your network SSID (name) 
char pass[] = "";           // your network password
int status = WL_IDLE_STATUS;

WiFiServer server(80);

bool issetup = false;

void setup() {
   delay(5000);
   Serial.begin(9600);
   Serial.println("Attempting to connect to WPA network...");
   Serial.print("SSID: ");
   Serial.println(ssid);

   status = WiFi.begin(ssid, pass);

   Serial.print("IP: ");
   IPAddress ip = WiFi.localIP();
   Serial.println(ip);

   // check for the presence of the shield:
   if (WiFi.status() == WL_NO_SHIELD) {
     Serial.println("WiFi shield not present"); 
     // don't continue:
     while(true);
   } 
  
   // attempt to connect to Wifi network:
   while ( status != WL_CONNECTED) { 
     Serial.print("Attempting to connect to SSID: ");
     Serial.println(ssid);
     // Connect to WPA/WPA2 network. Change this line if using open or WEP network:    
     status = WiFi.begin(ssid, pass);

     // wait 10 seconds for connection:
     delay(10000);
   } 
}
void loop() {
   WiFiClient client = server.available();
   if(client){                          // if there's a client, 
     Serial.println("New client: ");
     //if(client.available()) {         // if there's bytes to read from the client,
       Serial.println(client);
       char c = client.read();          // read a byte, then
       Serial.write(c);                 // print it out to the serial monitor
     //}
     client.stop();
   }
   //else{
   // Serial.print(".");
   //}
}
READ  VirtualBox USB Passthrough Guide

Motor

Arduino

This is sample code that shows how to write to a motor connected using an L298N module. Ultimately, this will be updated and written from the Client’s controls in the Wifi server file.
//This is just sample code, ultimately this will read from the JS joystick

int pinI1=;//define I1 port
int pinI2=1;//define I2 port
int speedpin=2;//define EA(PWM speed regulation)port
void setup()
{
 pinMode(pinI1,OUTPUT);//define this port as output
 pinMode(pinI2,OUTPUT);
 pinMode(speedpin,OUTPUT);
}
void loop()
{
 analogWrite(speedpin,100);//input a value to set the speed
 delay(2000);
 digitalWrite(pinI1,LOW);// DC motor rotates clockwise
 digitalWrite(pinI2,HIGH);
 analogWrite(speedpin,100);
 delay(2000);
 digitalWrite(pinI1,HIGH);// DC motor rotates anticlockwise
 digitalWrite(pinI2,LOW);
 analogWrite(speedpin,100);
 delay(2000);
 digitalWrite(pinI1,HIGH);// DC motor stop rotating
digitalWrite(pinI2,HIGH);
delay(2000);
}

Source : WiFi Robot




Leave a Comment

*
= 5 + 2

(Spamcheck Enabled)

Read previous post:
ADD A HOST OF 8-BIT PROCESSORS TO YOUR ARDUINO
ADD A HOST OF 8-BIT PROCESSORS TO YOUR ARDUINO

Normally when we bring you news of a retrocomputing design, it will centre around a single processor. At its heart...

Close
Scroll to top