this code successfully allows me to control a PWM from a web page the part I’m having trouble with is the test command part its supposed to execute the test command sequence when I insert the word test into the correct place in the IP address but all I get when I enter it is a blank page I’m wondering what I’m missing because I can’t tell what’s going wrong.
#include <Bridge.h>
#include <BridgeServer.h>
#include <BridgeClient.h>
#include <Console.h>
BridgeServer server;
int value;
int pin;
int onoff;
int value2;
int pin2;
int onoff2;
void setup() {
Bridge.begin();
server.listenOnLocalhost();
server.begin();
Console.begin();
}
void loop() {
BridgeClient client = server.accept();
if (client) {
process(client);
client.stop();
}
analogWrite(pin, value);
analogWrite(pin2, value2);
if (onoff == 1) {
digitalWrite (12, HIGH);
}
else {
digitalWrite (12, LOW);
}
if (onoff2 == 1) {
digitalWrite (2, HIGH);
}
else {
digitalWrite (2, LOW);
}
}
void process(BridgeClient client) {
String command = client.readStringUntil('/');
if (command == "analog") {
analogCommand(client);
}
if (command == "test") {
testCommand(client);
}
}
void analogCommand(BridgeClient client) {
pin = client.parseInt();
if (client.read() == '/') {
onoff = client.parseInt();
if (client.read() == '/') {
value = client.parseInt();
client.println(value);
if (value > 255) {
client.println("#Error PWM > 255#");
analogWrite(pin, 0);
}
if (client.read() == '/') {
pin2 = client.parseInt();
if (client.read() == '/') {
onoff2 = client.parseInt();
if (client.read() == '/') {
value2 = client.parseInt();
}
}
}
}
}
client.println("155.101.101.52/arduino/analog/pin/on or off/ PWM value/PIn for second high voltage/on or off for second battery/second PWM value");
}
void testCommand(BridgeClient client) {
client.println("running test");
client.println(pin);
client.print(":");
client.print(value);
client.println(pin2);
client.print(":");
client.print(value2);
}