No WiShield code:
- Code: Select all
int inputPin = 2; // choose the input pin (for a pushbutton)
int val = 0; // variable for reading the pin status
int prevState = 0;
void setup() {
pinMode(inputPin, INPUT); // declare pushbutton as input
Serial.begin(9600);
}
void loop(){
pinMode(inputPin, INPUT); // set pin to input
digitalWrite(inputPin, HIGH); // turn on pullup resistors
prevState = val;
val = digitalRead(inputPin); // read input value
if (val != prevState) {
if (val == HIGH) { // check if the input is HIGH
Serial.print("Gallon");
Serial.print("");
} else {
}
}
}
WiShield code:
- Code: Select all
#include <WiShield.h>
#define WIRELESS_MODE_INFRA 1
#define WIRELESS_MODE_ADHOC 2
// Wireless configuration parameters ----------------------------------------
unsigned char local_ip[] = {192,168,10,xx}; // IP address of WiShield
unsigned char gateway_ip[] = {192,168,10,1}; // router or gateway IP address
unsigned char subnet_mask[] = {255,255,255,0}; // subnet mask for the local network
const prog_char ssid[] PROGMEM = {"asfasdfads"}; // max 32 bytes
unsigned char security_type = 3; // 0 - open; 1 - WEP; 2 - WPA; 3 - WPA2
const prog_char security_passphrase[] PROGMEM = {"asfadsasdf"}; // max 64 characters
prog_uchar wep_keys[] PROGMEM = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, // Key 0
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Key 1
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Key 2
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // Key 3
};
unsigned char wireless_mode = WIRELESS_MODE_INFRA;
unsigned char ssid_len;
unsigned char security_passphrase_len;
//---------------------------------------------------------------------------
int inputPin = 5; // choose the input pin (for a pushbutton)
int val = 0; // variable for reading the pin status
int prevState = 0;
void setup() {
pinMode(inputPin, INPUT); // declare pushbutton as input
Serial.begin(9600);
WiFi.init();
}
unsigned char loop_cnt = 0;
char ip[] = {xxx,xx,225,182};
const prog_char twitter[] PROGMEM = {"POST /xxxxx HTTP/1.1\r\nUser-Agent: uIP/1.0\r\nHost: xxxx\r\nContent-Length: 6\r\nContent-Type: application/x-www-form-urlencoded\r\n\r\nGallon"};
void loop() {
pinMode(inputPin, INPUT); // set pin to input
digitalWrite(inputPin, HIGH); // turn on pullup resistors
prevState = val;
val = digitalRead(inputPin); // read input value
if (val != prevState) {
if (val == HIGH) { // check if the input is HIGH
webclient_get(ip, 80, "/");
Serial.print("Gallon");
} else {
}
}
WiFi.run();
}