Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Understood, but:... "latency problem between a PC key press and the operation of a remote relay, not very spontaneous." ...
(My emphasis)It would take at least 5 second from PC to Arduino to actually switch off the relay
Yes, please. In particular, I'm interested in the WiFi portions, i.e., is a new WiFi connection made for each command or is it kept open for a prolonged "session"?... anyone willing to modify the code? If so I will provide the current code. ...
In the video the Delay value 5 is changed to 100, this slows the rotation.servoA.write(position++);
delay(5); //change it to 100
}
if(buttonState2 == HIGH && position > 3){
servoA.write(position--);
delay(5); //change it to 100
}
}
#include <Wire.h>
#include <ArduinoWiFi.h>
#define CH1 4 // Connect Digital Pin 4 on Arduino to CH1 on Relay Module
#define LEDgreen 13 // Connect Digital Pin 13 on Arduino to Green LED
/*
on your borwser, you type http://<IP>/arduino/webserver/ or http://<hostname>.local/arduino/webserver/
http://www.arduino.org/learning/tutorials/webserverblink
*/
void setup() {
pinMode(CH1, OUTPUT); // define realy on
pinMode(13,OUTPUT); // define
Wifi.begin();
Wifi.println("WebServer Server is up");
}
void loop() {
while(Wifi.available()){
process(Wifi);
}
delay(50);
}
void process(WifiData client) {
// read the command
String command = client.readStringUntil('/');
// is "digital" command?
if (command == "webserver") {
WebServer(client);
}
if (command == "digital") {
digitalCommand(client);
}
}
void WebServer(WifiData client) {
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println();
client.println("<html>");
client.println("<head> </head>");
client.print("<body>");
client.print("Click<input type=button onClick=\"var w=window.open('/arduino/digital/13/1','_parent');w.close();\"value='ON'>pin13 ON<br>");
client.print("Click<input type=button onClick=\"var w=window.open('/arduino/digital/13/0','_parent');w.close();\"value='OFF'>pin13 OFF<br>");
client.print("</body>");
client.println("</html>");
client.print(DELIMITER); // very important to end the communication !!!
}
void digitalCommand(WifiData client) {
int pin, value;
// Read pin number
pin = client.parseInt();
// If the next character is a '/' it means we have an URL
// with a value like: "/digital/13/1"
if (client.read() == '/') {
value = client.parseInt();
digitalWrite(pin, value);
digitalWrite(CH1,HIGH); // Turns ON Led1
delay(3000); // Wait 1 seconds
digitalWrite(CH1,LOW); // Turns OFF Led1
delay(1000); // Wait 1 seconds
}
// Send feedback to client
client.println("Status: 200 OK\n");
client.print(F("Pin D"));
client.print(pin);
client.print(F(" set to "));
client.print(value);
client.print(EOL); //char terminator
}
Two weeks ago (Post #40):... In the video the Delay value 5 is changed to 100, this slows the rotation. ...
Anyway... Making some progress here.... To control the "sweep" speed, adjust the "Delay" value (in mS) to suit your needs, i.e., higher value = slower rotation, etc.. ...
Well at some point I did thought of redoing this project again,I might suggest, at this point, that this project may need a re-boot. Believe me, I am very sympathetic to your development efforts and the time that represents. I've been there.
But I think your goal can be reached with a considerably less complex and much more responsive system, if your willing to start over. Not an easy decision, of that I am sure.
What do you think? It'll still be your creation: Just a little external guidance here and there...
For number 2, this link might help:2. Establish basic WiFi comms (with with simple LED ON/OFF commands embedded in the code) between the two Arduinos - test for speed,
3. Add PWM code to remote Arduino and test servo response.
Let's assume, for the moment, that the WiFi Uno has corrupted code, rather than hardware issues.Right now the Uno wifi is experiencing some problem ...