I'm trying to get data from a txt file through my website to turn the LED on or off, the connection to the website works and the data from a txt file is printed on the serial as the code shows, but on the loop condition when I read a txt file with '1' it should light on the LED, but that does not work
can you please help me
this is my code
#include <SPI.h>
#include <WiFi.h>
char ssid[] = "HomeBroadband"; // your network SSID (name)
char pass[] = "h12345678"; // 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[] = "daffostore.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() {
//Initialize serial and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
// check for the presence of the shield:
if (WiFi.status() == WL_NO_SHIELD) {
Serial.println("WiFi shield not present");
// don't continue:
while (true);
}
String fv = WiFi.firmwareVersion();
if (fv != "1.1.0") {
Serial.println("Please upgrade the firmware");
}
// 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) == 1) {
Serial.println("connected to server");
// Make a HTTP request:
client.println("GET /ard/ledstatus.txt HTTP/1.1");
client.println("Host: daffostore.com");
client.println("Connection: keep-alive");
//client.println("Content-Length: 1845");
client.println("Keep-Alive: timeout=10, max=20");
client.println();
}
}
void loop() {
// if there are incoming bytes available
// from the server, read them and print them:
while (client.available()) {
char c = client.read();
Serial.write(c);
if(c=='1'){
digitalWrite(13, HIGH);
}
else{
digitalWrite(13, LOW);
}
}
// if the server's disconnected, stop the client:
if (!client.connected()) {
Serial.println();
Serial.println("disconnecting from server.");
client.stop();
// do nothing forevermore:
while (true);
}
}
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");
}
Related
Here what I try to do I have quickapp in HC3 that have some buttons I want to call from ESP8266 with it's URL All buttons API is working fine in browser
the project consist of {ESP8266, IR Receiver} that is it
I want to make conditions for the buttons that IR receive I will get it's code from serial monitor
and every button it's condition come true is calling Certain button in fibaro quickapp through API
How can I make API call under every (condition) OR (case) from arduino
I am trying to call button in quick app, if IR receive any code from AC remote it will call the API of this button
the arduino code is this
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#include <Arduino.h>
#include <IRremoteESP8266.h>
#include <IRrecv.h>
#include <IRutils.h>
#define ssid "Name"
#define password "Passsword"
const char * servername = "http://User:Password#IPAdress/api/plugins/callUIEvent?deviceID=1639&elementName=Cool22&eventType=onReleased";
int MyData;
IRrecv irrecv(14);
decode_results results;
void setup()
{
MyData = 0;
WiFi.mode(WIFI_STA);
WiFi.begin(ssid,password);
Serial.begin(9600);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.print("connected to ");
Serial.println(ssid);
Serial.print("IP Adress: ");
Serial.println(WiFi.localIP());
irrecv.enableIRIn(); // Start the receiver
}
/*while (!Serial){ // Wait for the serial connection to be establised.
delay(50);
Serial.println();
Serial.print("IRrecv is now running and waiting for IR message on Pin ");
Serial.println(14);
}*/
void loop()
{
HTTPClient http;
WiFiClient client;
if (irrecv.decode(&results)) {
Serial.println("You Receive This:");
MyData = (results.value);
Serial.println(MyData);
if (MyData == 11714416 ){
http.begin(client, servername);
http.addHeader("Content-Type", "application/json");
int httpcode = http.POST(servername);
String payload =(http.getString());
Serial.println(payload);
Serial.print("HTTP Response code: ");
Serial.println(httpcode);
// Disconnect
http.end();
}
else {
Serial.println("No HTTP");
}
irrecv.resume();
}
}
the output tell me
You Receive This:
11714416
HTTP Response code: -1
and sometimes it give me Exception(28)
I'm trying to stream voice to the MQTT broker. I'm using esp8266(NodeMCU1.0) and it's ADC to sampling the audio signal at 4KHz and 8-bit PCM audio format. I used Pubsubclient.h library to publish audio packets to the broker but on the other side when I receive packets and play them I have the interrupted voice and I have a delay between playing packets as long as my buffer size. please help me to have continues voice.
I have 2 main problems:
1) delay between playing packets as long as my buffer size
example of what i received: ;D ;D ;D .....|||||..........|||||||...........|||||||||............||||||||
2) Quality of voice: I receive a noisy voice.
Please help me! Thanks.
#include <ESP8266WiFi.h>
#include <PubSubClient.h>
const char* ssid = "Knight";
const char* password = "****";
const char* mqtt_server = "104.21.218.224";
WiFiClient espClient;
PubSubClient client(espClient);
unsigned long lastMsg = 0;
#define MSG_BUFFER_SIZE (4096)
int i;
byte voice[MSG_BUFFER_SIZE];
void setup_wifi() {
delay(10);
// We start by connecting to a WiFi network
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
randomSeed(micros());
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
}
void reconnect() {
// Loop until we're reconnected
while (!client.connected()) {
Serial.print("Attempting MQTT connection...");
// Create a random client ID
String clientId = "ashkan";
// Attempt to connect
if (client.connect(clientId.c_str())) {
Serial.println("connected");
// Once connected, publish an announcement...
if (!client.publish("doorphone/connected", "true")) {
Serial.println("publish failed, either connection lost, or message too large");
}
else {
Serial.println("publish succeeded");
}
// ... and resubscribe
// client.subscribe("doorphone/open");
} else {
Serial.print("failed, rc=");
Serial.print(client.state());
Serial.println(" try again in 5 seconds");
// Wait 5 seconds before retrying
delay(5000);
}
}
}
void setup() {
pinMode(BUILTIN_LED, OUTPUT); // Initialize the BUILTIN_LED pin as an output
Serial.begin(115200);
setup_wifi();
client.setServer(mqtt_server, 1883);
}
void loop() {
if (!client.connected()) {
reconnect();
}
client.loop();
for (i = 0; i < MSG_BUFFER_SIZE; i++) {
voice[i] = analogRead(A0);
// client.write(voice[i]);
delayMicroseconds(125);
}
client.publish("doorphone/connected", voice, MSG_BUFFER_SIZE);
}
I am trying to display Temperature and Humidity reading of SHT31 sensor on the HTML page,
but whenever I am trying to write the IP in the web browser and searching, the Error - "This site can not be reached" has been displayed.
I am working on code(mentioned below) to connect and Interfacing I2C module of Temperature sensor with Adafruit Huzzah ESP8266 using Library "ESP8266WiFi.h", "Wire.h"
#include <ESP8266WiFi.h>
#include <Wire.h>
// SHT31 I2C address is 0x44(68)
#define Addr 0x44
// Replace with your network credentials
const char* ssid = "SSID";
const char* password = "Password";
float Ctemp,Ftemp,humid;
// Set web server port number to 80
WiFiServer server(80);
// Variable to store the HTTP request
String header;
void setup()
{
Wire.begin(2,14);
Serial.begin(115200);
// Connect to Wi-Fi network with SSID and password
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
// Print local IP address and start web server
Serial.println("");
Serial.println("WiFi connected.");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
server.begin();
}
void loop(){
temptask();
WiFiClient client = server.available(); // Listen for incoming clients
if (client)
{ // If a new client connects,
Serial.println("New Client."); // print a message out in the serial port
String currentLine = ""; // make a String to hold incoming data from the client
while (client.connected()) { // loop while the client's connected
if (client.available()) { // if there's bytes to read from the client,
char c = client.read(); // read a byte, then
Serial.write(c); // print it out the serial monitor
header += c;
if (c == '\n') { // if the byte is a newline character
// if the current line is blank, you got two newline characters in a row.
// that's the end of the client HTTP request, so send a response:
if (currentLine.length() == 0) {
// HTTP headers always start with a response code (e.g. HTTP/1.1 200 OK)
// and a content-type so the client knows what's coming, then a blank line:
client.println("HTTP/1.1 200 OK");
client.println("Content-type:text/html");
client.println("Connection: close");
client.println();
// Display the HTML web page
client.println("<!DOCTYPE html><html>");
client.println("<head><meta charset=\"utf-8\">");
client.println("<meta name = \"viewport\" content = \"width = device-width, initial-scale = 1.0\">");
client.println("<body style= \"background-color:#EDEEF2\">");
client.println("<h1 style= \"color:blue\">Temperature and Humidity</h1>");
client.println( "<h3 style= \"font-family:verdana; color:blue\">Temperature in Celcius:</h3>");
client.println("<p style=\"font-size:160%; font-family:Lucida Console\">"+String(Ctemp,1)+"</p>");
client.println("<h3 style= \"font-family:verdana; color:blue\">Temperature in Fahrenheit:</h3>");
client.println("<p style=\"font-size:160%; font-family:Lucida Console\">"+String(Ftemp,1)+"</p>");
client.println("<h3 style= \"font-family:verdana; color:blue\">Humidity:</h3>");
client.println("<p style=\"font-size:160%; font-family:Lucida Console\">"+String(humid,1)+"</p>");
client.println("</body>");
client.println("</html>");
break;
}
}
}
// Clear the header variable
header = "";
// Close the connection
client.stop();
Serial.println("Client disconnected.");
Serial.println("");
}
}
}
void temptask(){
unsigned int data[6];
// Start I2C Transmission
Wire.beginTransmission(Addr);
// Send 16-bit command byte
Wire.write(0x2C);
Wire.write(0x06);
// Stop I2C transmission
Wire.endTransmission();
delay(300);
// Start I2C Transmission
Wire.beginTransmission(Addr);
// Stop I2C Transmission
Wire.endTransmission();
// Request 6 bytes of data
Wire.requestFrom(Addr, 6);
// Read 6 bytes of data
// temp msb, temp lsb, temp crc, hum msb, hum lsb, hum crc
if (Wire.available() == 6)
{
data[0] = Wire.read();
data[1] = Wire.read();
data[2] = Wire.read();
data[3] = Wire.read();
data[4] = Wire.read();
data[5] = Wire.read();
}
// Convert the data
int temp = (data[0] * 256) + data[1];
float cTemp = -45.0 + (175.0 * temp / 65535.0);
float fTemp = (cTemp * 1.8) + 32.0;
float humidity = (100.0 * ((data[3] * 256.0) + data[4])) / 65535.0;
Ctemp = cTemp;
Ftemp = fTemp;
humidity = humid;
Serial.print("Temperature in C:\t");
Serial.println(String(cTemp,1));
Serial.print("Temperature in F:\t");
Serial.println(String(fTemp,1));
Serial.print("Humidity:\t ");
Serial.println(String(humidity,1));
}
Any advice about what causing this issue will very grateful.
I have updated your code and is working fine now kindly take a look.
#include <ESP8266WiFi.h>
#include <Wire.h>
#include <ESP8266WebServer.h>
// SHT31 I2C address is 0x44(68)
#define Addr 0x44
// Replace with your network credentials
const char* ssid = "DcubeAirtel";
const char* password = "D#Airtel190";
float Ctemp,Ftemp,humid;
// Set web server port number to 80
WiFiServer server(80);
// Variable to store the HTTP request
String header;
void setup()
{
Wire.begin(2,14);
Serial.begin(115200);
// Connect to Wi-Fi network with SSID and password
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
// Print local IP address and start web server
Serial.println("");
Serial.println("WiFi connected.");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
server.begin();
}
void loop(){
temptask();
WiFiClient client = server.available(); // Listen for incoming clients
if (client)
{ // If a new client connects,
Serial.println("New Client."); // print a message out in the serial port
String currentLine = ""; // make a String to hold incoming data
from the client
while (client.connected()) { // loop while the client's connected
if (client.available()) { // if there's bytes to read from the
client,
String c = client.readStringUntil('\r'); // read a byte, then
Serial.println(c);
} // print it out the serial monitor
// if the current line is blank, you got two newline characters in a row.
// that's the end of the client HTTP request, so send a response:
// HTTP headers always start with a response code (e.g. HTTP/1.1 200 OK)
// and a content-type so the client knows what's coming, then a blank line:
client.println("HTTP/1.1 200 OK");
client.println("Content-type:text/html");
client.println("Connection: close");
client.println();
String PAGE2 =
"<!DOCTYPE html>"
"<html>"
"<head>"
"<meta charset=\"utf-8\">"
"<meta name = \"viewport\" content = \"width = device-width, initial-scale = 1.0\">"
"<title> My first HTML page</title>"
"</head>"
"<body style= \"background-color:#EDEEF2\">"
"<h1 style= \"color:blue\">Temperature and Humidity</h1>"
"<h3 style= \"font-family:verdana; color:blue\">Temperature in Celcius:</h3>"
"<p style=\"font-size:160%; font-family:Lucida Console\">"+String(Ctemp,1)+
"</p>"
"<h3 style= \"font-family:verdana; color:blue\">Temperature in Fahrenheit:</h3>"
"<p style=\"font-size:160%; font-family:Lucida Console\">"+String(Ftemp,1)+
"</p>"
"<h3 style= \"font-family:verdana; color:blue\">Humidity:</h3>"
"<p style=\"font-size:160%; font-family:Lucida Console\">"+String(humid,1)+
"</p>"
"</body>"
"</html>";
// Display the HTML web page
client.println(PAGE2);
}
}
// Clear the header variable
// Close the connection
client.stop();
Serial.println("Client disconnected.");
Serial.println("");
}
void temptask(){
unsigned int data[6];
// Start I2C Transmission
Wire.beginTransmission(Addr);
// Send 16-bit command byte
Wire.write(0x2C);
Wire.write(0x06);
// Stop I2C transmission
Wire.endTransmission();
delay(300);
// Start I2C Transmission
Wire.beginTransmission(Addr);
// Stop I2C Transmission
Wire.endTransmission();
// Request 6 bytes of data
Wire.requestFrom(Addr, 6);
// Read 6 bytes of data
// temp msb, temp lsb, temp crc, hum msb, hum lsb, hum crc
if (Wire.available() == 6)
{
data[0] = Wire.read();
data[1] = Wire.read();
data[2] = Wire.read();
data[3] = Wire.read();
data[4] = Wire.read();
data[5] = Wire.read();
}
// Convert the data
int temp = (data[0] * 256) + data[1];
float cTemp = -45.0 + (175.0 * temp / 65535.0);
float fTemp = (cTemp * 1.8) + 32.0;
float humidity = (100.0 * ((data[3] * 256.0) + data[4])) / 65535.0;
Ctemp = cTemp;
Ftemp = fTemp;
humidity = humid;
Serial.print("Temperature in C:\t");
Serial.println(String(cTemp,1));
Serial.print("Temperature in F:\t");
Serial.println(String(fTemp,1));
Serial.print("Humidity:\t ");
Serial.println(String(humidity,1));
}
This works as follows:
First read the char sent by server till next line
Now flush the server
Now write your content to the server.
I am trying to upload data from arduino to a local server using Arduino wifi shied.But the code never reaches the line "connected".I am using WAMP server.The IP address ping of the arduino wifi shield is okay.The wifi shield connects to the network.The code is below:
#include <TinkerKit.h>
#include <WiFi.h>
#include <SPI.h>
char ssid[] = "Connectify-moloi"; // your network SSID (name)
char pass[] = "1234567890"; // your network password
int status = WL_IDLE_STATUS;
//WiFiServer server(80);
long previousMillis = 0;
unsigned long currentMillis = 0;
long interval = 250000; // READING INTERVAL
int sensor;
int analog_val;
String data;
String Hall;
String Temp;
WiFiClient client;
IPAddress server(192,168,164,101);
void setup() {
Serial.begin(9600);
while ( status != WL_CONNECTED) {
Serial.print("Attempting to connect to SSID: ");
Serial.println(ssid);
status = WiFi.begin(ssid, pass);
// wait 10 seconds for connection:
delay(10000);
}
// you're connected now, so print out the status:
printWifiStatus();
Hall = "50";
Temp = "50";
data = "";
}
void loop(){
currentMillis = millis();
if(currentMillis - previousMillis > interval) { // READ ONLY ONCE PER INTERVAL
previousMillis = currentMillis;
Hall ="50"; //String(analog_val);
Temp ="50"; //String(sensor);
}
data = "temp1=" + Hall + "&hum1=" + Temp;
client.flush();
if (client.connect(server,80)) { // REPLACE WITH YOUR SERVER ADDRESS
Serial.println("Connected");
client.println("POST project/add.php HTTP/1.1");
client.println("Host: 192.168.164.101"); // SERVER ADDRESS HERE TOO
client.println("Content-Type: application/x-www-form-urlencoded");
client.print("Content-Length: ");
client.println(data.length());
client.println();
client.print(data);
}
if (client.connected()) {
client.stop(); // DISCONNECT FROM THE SERVER
client.flush();
}
delay(7000); // WAIT FIVE MINUTES BEFORE SENDING AGAIN
}
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");
}
Instead of a POST command, try using a GET request.
Change POST project/add.php to GET /project/add.php?
I am currently involved in a project which needs to have 4 led's and one stepper motor to be turned on/off independently over wifi.
Just to mention Im using an Uno r3, official Wifi shield and official motor shield.
I have the 4 led's working on pins A2-A5 or in my code pins (16-19) leaving free all digital pins and have set up my stepper motor to pins 9,8,6,5. When i go to the ip address i can turn off/on each LED independently but with the stepper motor it either judders and does not move or nothing at all.
I have posted my code so far below, would really appreciate any help or advice. Thanks
/*
WiFi Web Server LED Blink
A simple web server that lets you blink an LED via the web.
This sketch will print the IP address of your WiFi Shield (once connected)
to the Serial monitor. From there, you can open that address in a web browser
to turn on and off the LED on pin 9.
This example is written for a network using WPA encryption. For
WEP or WPA, change the Wifi.begin() call accordingly.
Circuit:
* WiFi shield attached
* LED attached to pin 9
created 25 Nov 2012
by Tom Igoe
*/
#include <SPI.h>
#include <WiFi.h>
#include <Stepper.h>
char ssid[] = "username"; // your network SSID (name)
char pass[] = "password"; // your network password
int keyIndex = 0;
int delaylegnth = 7;
int state = 0;
int x = 0;
// your network key Index number (needed only for WEP)
int status = WL_IDLE_STATUS;
WiFiServer server(80);
void setup() {
Serial.begin(9600); // initialize serial communication
pinMode(16, OUTPUT); // set the LED pin mode
pinMode(17, OUTPUT); // set the LED pin mode
pinMode(18, OUTPUT); // set the LED pin mode
pinMode(19, OUTPUT); // set the LED pin mode
//establish motor direction toggle pins
pinMode(5, OUTPUT); //CH A -- HIGH = forwards and LOW = backwards???
pinMode(6, OUTPUT); //CH B -- HIGH = forwards and LOW = backwards???
//establish motor brake pins
pinMode(9, OUTPUT); //brake (disable) CH A
pinMode(8, OUTPUT); //brake (disable) CH B
// check for the presence of the shield:
if (WiFi.status() == WL_NO_SHIELD) {
Serial.println("WiFi shield not present");
while(true); // don't continue
}
// attempt to connect to Wifi network:
while ( status != WL_CONNECTED) {
Serial.print("Attempting to connect to Network named: ");
Serial.println(ssid); // print the network name (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);
}
server.begin(); // start the web server on port 80
printWifiStatus(); // you're connected now, so print out the status
}
void loop() {
WiFiClient client = server.available(); // listen for incoming clients
if (client) { // if you get a client,
Serial.println("new client"); // print a message out the serial port
String currentLine = ""; // make a String to hold incoming data from the client
String currentLine2 = "";
String currentLine3 = "";
String currentLine4 = "";
String currentLine5 = "";
while (client.connected()) { // loop while the client's connected
if (client.available()) { // if there's bytes to read from the client,
char c = client.read(); // read a byte, then
Serial.write(c); // print it out the serial monitor
if (c == '\n') { // if the byte is a newline character
// if the current line is blank, you got two newline characters in a row.
// that's the end of the client HTTP request, so send a response:
if (currentLine.length() == 0) {
// HTTP headers always start with a response code (e.g. HTTP/1.1 200 OK)
// and a content-type so the client knows what's coming, then a blank line:
client.println("HTTP/1.1 200 OK");
client.println("Content-type:text/html");
client.println();
// the content of the HTTP response follows the header:
client.print("Click here turn the LED on pin 4 on<br>");
client.print("Click here turn the LED on pin 4 off<br>");
client.print("Click here turn the LED on pin 5 on<br>");
client.print("Click here turn the LED on pin 5 off<br>");
client.print("Click here turn the LED on pin 6 on<br>");
client.print("Click here turn the LED on pin 6 off<br>");
client.print("Click here turn the LED on pin 2 on<br>");
client.print("Click here turn the LED on pin 2 off<br>");
client.print("Click here turn the Stepper<br>");
// The HTTP response ends with another blank line:
client.println();
// break out of the while loop:
break;
}
else { // if you got a newline, then clear currentLine:
currentLine = "";
currentLine2 = "";
currentLine3 = "";
currentLine4 = "";
currentLine5 = "";
}
}
else if (c != '\r') { // if you got anything else but a carriage return character,
currentLine += c;
currentLine2 += c;
currentLine3 += c;
currentLine4 += c;
currentLine5 += c;
}
// Check to see if the client request was "GET /H" or "GET /L":
if (currentLine.endsWith("GET /H")) {
digitalWrite(16, HIGH); // GET /H turns the LED on
}
if (currentLine.endsWith("GET /L")) {
digitalWrite(16, LOW); // GET /L turns the LED off
}
if (currentLine2.endsWith("GET /A")) {
digitalWrite(17, HIGH); // GET /A turns the LED on
}
if (currentLine2.endsWith("GET /B")) {
digitalWrite(17, LOW); // GET /B turns the LED off
}
if (currentLine3.endsWith("GET /C")) {
digitalWrite(18, HIGH); // GET /A turns the LED on
}
if (currentLine3.endsWith("GET /D")) {
digitalWrite(18, LOW); // GET /B turns the LED off
}
if (currentLine4.endsWith("GET /E")) {
digitalWrite(19, HIGH); // GET /A turns the LED on
}
if (currentLine4.endsWith("GET /F")) {
digitalWrite(19, LOW); // GET /B turns the LED off
}
}
if (currentLine5.endsWith("GET /G")) { //stepper motor
// for(int x; x < 500; x++) {
// state=digitalRead(0);
// if (state == LOW){
digitalWrite(9, LOW); //ENABLE CH A
digitalWrite(8, HIGH); //DISABLE CH B
digitalWrite(5, HIGH); //Sets direction of CH A
analogWrite(A0, 255); //Moves CH A
// }
// else{
delay(delaylegnth);
digitalWrite(9, HIGH); //DISABLE CH A
digitalWrite(8, LOW); //ENABLE CH B
digitalWrite(6, LOW); //Sets direction of CH B
analogWrite(A1, 255); //Moves CH B
delay(delaylegnth);
digitalWrite(9, LOW); //ENABLE CH A
digitalWrite(8, HIGH); //DISABLE CH B
digitalWrite(5, LOW); //Sets direction of CH A
analogWrite(A0, 255); //Moves CH A
delay(delaylegnth);
digitalWrite(9, HIGH); //DISABLE CH A
digitalWrite(8, LOW); //ENABLE CH B
digitalWrite(6, HIGH); //Sets direction of CH B
analogWrite(A1, 255); //Moves CH B
delay(delaylegnth);
// }
// }
}
}
// close the connection:
client.stop();
Serial.println("client disonnected");
}
}
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");
// print where to go in a browser:
Serial.print("To see this page in action, open a browser to http://");
Serial.println(ip);
}