problem with wifi shield and motor shield
hello, after using of members of forum have succed control
two engine wifi card (arduino wifi shield http://arduino.cc/en/main/arduinowifishield) and
the motor card (arduino motor shield http://www.instructables.com/id/arduino-motor-shield-tutorial/?allsteps) problem in pin 9 since reserved wifi card presents error
who can me ,for exemple can change motor 2 to
work pin or anything, need
this arduino code
two engine wifi card (arduino wifi shield http://arduino.cc/en/main/arduinowifishield) and
the motor card (arduino motor shield http://www.instructables.com/id/arduino-motor-shield-tutorial/?allsteps) problem in pin 9 since reserved wifi card presents error
who can me ,for exemple can change motor 2 to
work pin or anything, need
this arduino code
code: [select]
#include <spi.h>
#include <wifi.h>
char ssid[] = "mon reseau wifi"; // network ssid (name)
char pass[] = "mon mot de passe"; // network password
int keyindex = 0; // network key index number (needed wep)
int status = wl_idle_status;
wifiserver server(80);
void setup() {
serial.begin(9600); // initialize serial communication
pinmode(22, output);
////
pinmode(12, output);
pinmode(13, output);
//establish motor brake pins
pinmode(9, output);
pinmode(8, output);
//turns brake off drive motor
digitalwrite(9, high);
digitalwrite(8, high);
//
// check presence of shield:
if (wifi.status() == wl_no_shield) {
serial.println("wifi shield not present");
while (true); // don't continue
}
string fv = wifi.firmwareversion();
if ( fv != "1.1.0" )
serial.println("please upgrade firmware");
// attempt connect wifi network:
while ( status != wl_connected) {
serial.print("attempting connect network named: ");
serial.println(ssid); // print network name (ssid);
// connect wpa/wpa2 network. change line if using open or wep network:
status = wifi.begin(ssid, pass);
// wait 10 seconds connection:
delay(10000);
}
server.begin(); // start web server on port 80
printwifistatus(); // you're connected now, print out status
}
void loop() {
wificlient client = server.available(); // listen incoming clients
if (client) { // if client,
serial.println("new client"); // print message out serial port
string currentline = ""; // make string hold incoming data client
while (client.connected()) { // loop while client's connected
if (client.available()) { // if there's bytes read client,
char c = client.read(); // read byte, then
serial.write(c); // print out serial monitor
if (c == '\n') { // if byte newline character
// if current line blank, got 2 newline characters in row.
// that's end of client http request, send response:
if (currentline.length() == 0) {
// http headers start response code (e.g. http/1.1 200 ok)
// , content-type client knows what's coming, blank line:
client.println("http/1.1 200 ok");
client.println("content-type:text/html");
client.println();
// content of http response follows header:
client.print("<a href=\"/f\">avant</a><br>");
client.print("<a href=\"/b\">arriere</a><br>");
client.print("<a href=\"/d\">droite</a><br>");
client.print("<a href=\"/g\">gauche</a><br>");
client.print("<a href=\"/a\">arret</a><br>");
client.print("<a href=\"/n\">mode nuit</a><br>");
client.print("<a href=\"/j\">mode jour</a><br>");
// http response ends blank line:
client.println();
// break out of while loop:
break;
}
else { // if got newline, clear currentline:
currentline = "";
}
}
else if (c != '\r') { // if got else carriage return character,
currentline += c; // add end of currentline
}
// check client request
if (currentline.endswith("get /f")) {
digitalwrite(12, high);
digitalwrite(13, high);
digitalwrite(9, low);
digitalwrite(8, low);
analogwrite(3, 200);
analogwrite(11, 200);
}
if (currentline.endswith("get /a")) {
digitalwrite(9, high);
digitalwrite(8, high);
}
if (currentline.endswith("get /b")) {
digitalwrite(12, low);
digitalwrite(13, low);
digitalwrite(9, low);
digitalwrite(8, low);
analogwrite(3, 123);
analogwrite(11, 123);
}
if (currentline.endswith("get /d")) {
digitalwrite(12, high);
digitalwrite(13, low);
digitalwrite(9, low);
digitalwrite(8, low);
analogwrite(3, 123);
analogwrite(11, 200);
}
if (currentline.endswith("get /g")) {
digitalwrite(12, low);
digitalwrite(13, high);
digitalwrite(9, low);
digitalwrite(8, low);
analogwrite(11, 123);
analogwrite(3, 200);
}
if (currentline.endswith("get /n")) {
digitalwrite(22, high);
}
if (currentline.endswith("get /j")) {
digitalwrite(22, low);
}
}
}
// close connection:
client.stop();
serial.println("client disonnected");
}
}
void printwifistatus() {
// print ssid of network you're attached to:
serial.print("ssid: ");
serial.println(wifi.ssid());
// print wifi shield's ip address:
ipaddress ip = wifi.localip();
serial.print("ip address: ");
serial.println(ip);
// print received signal strength:
long rssi = wifi.rssi();
serial.print("signal strength (rssi):");
serial.print(rssi);
serial.println(" dbm");
// print go in browser:
serial.print("to see page in action, open browser http://");
serial.println(ip);
}
no 1 can give me idea
Arduino Forum > Using Arduino > Motors, Mechanics, and Power (Moderator: fabioc84) > problem with wifi shield and motor shield
arduino
Comments
Post a Comment