Hi,
I am trying to code for a specific sequence of 6 FSRs inputs that trigger a wifi connection. (once the correct sequence has been received the wifi shield connects to a specific http:// address.
I would really appreciate any help!
Thanks
Dian
// sketch for a sequence of fsr that trigger a wifi connection
#include <SPI.h>
#include <WiFi.h>
const int fsrOne=A0;
const int fsrTwo=A1;
const int fsrThree=A2;
const int fsrFour=A3;
const int fsrFive=A4;
const int fsrSix=A5;
int fsrReading1=0;
int fsrReading2=0;
int fsrReading3=0;
int fsrReading4=0;
int fsrReading5=0;
int fsrReading6=0;
char ssid[] = "Your network"; // your network SSID (name)
char pass[] = "passsword"; // your network password (use for WPA, or use as key for WEP)
int keyIndex = 0; // your network key Index number (needed only for WEP)
int status = WL_IDLE_STATUS;
// if you don't want to use DNS (and reduce your sketch size)
// use the numeric IP instead of the name for the server:
//IPAddress server(74,125,232,128); // numeric IP for Google (no DNS)
char server[] = "www.google.com"; // name address for Google (using DNS)
// Initialize the Ethernet client library
// with the IP address and port of the server
// that you want to connect to (port 80 is default for HTTP):
WiFiClient client;
void setup(){
Serial.begin(9600);
}
void loop(){
fsrReading1=analogRead(fsrOne);
fsrReading2=analogRead(fsrTwo);
fsrReading3=analogRead(fsrThree);
fsrReading4=analogRead(fsrFour);
fsrReading5=analogRead(fsrFive);
fsrReading6=analogRead(fsrSix);
/* if the FSR1 and FSR2 are both HIGH, then execute serial print.
if after this, and in sequence 3, 4 and 5 are HIGH then wifi connects to http://
*/
if (fsrReading1>=100 && fsrReading2>=100) { // fsr1 and fsr2 are both being pressed
Serial.println("Ready to begin sequence");
delay(2000);
}
if (fsrReading3>=100 &&fsrReading4>=100) {
Serial.println("Great! almost there"); // second part of the sequence
delay(2000);
}
if (fsrReading5>=100 && fsrReading6>=100){ // final step of sequence, this triggers the wifi connection
Serial.println("wifi connecting");
delay(2000);
// 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);
}
Serial.println("Connected to wifi");
printWifiStatus();
Serial.println("\nStarting connection to server...");
// if you get a connection, report back via serial:
if (client.connect(server, 80)) {
Serial.println("connected to server");
// Make a HTTP request:
client.println("GET /search?q=arduino HTTP/1.1");
client.println("Host: www.google.com");
client.println("Connection: close");
client.println();
}
void printWifiStatus() // print the SSID of the network you're attached to:
Serial.print("SSID: ");
Serial.println(WiFi.SSID());
// print your WiFi shield's IP address:
IPAddress ip = WiFi.localIP();
Serial.print("IP Address: ");
Serial.println(ip);
// print the received signal strength:
long rssi = WiFi.RSSI();
Serial.print("signal strength (RSSI):");
Serial.print(rssi);
Serial.println(" dBm");
}
}
Here are my errors:
code_for_forum_help.ino: In function 'void loop()':
code_for_forum_help:84: error: 'printWifiStatus' was not declared in this scope
code_for_forum_help:99: error: expected initializer before 'Serial'