So I'm trying to combine the blink and bridge example to get a pwm but it doesnt appear to be working correctly it will turn on a very dim light that wont change no matter what number I originaly input or what I change it to and I have no idea why its doing that I was hopeing someone might be able to see whats going on.
here is my entire code
#include <Bridge.h>
#include <BridgeServer.h>
#include <BridgeClient.h>
BridgeServer server;
int value;
int pin;
unsigned long previousmillies = 0;
const long total = 255;
void setup() {
Bridge.begin();
server.listenOnLocalhost();
server.begin();
Console.begin();
}
unsigned long currentmillies = millis();
void loop() {
BridgeClient client = server.accept();
if (client) {
process(client);
client.stop();
}
if (total - value >= currentmillies - previousmillies && currentmillies - previousmillies <= total)
{
analogWrite(pin, HIGH);
}
//if (total - value >= currentmillies && currentmillies - previousmillies <= total) {
else {
analogWrite(pin, LOW);
previousmillies = currentmillies;
}
}
void process(BridgeClient client) {
String command = client.readStringUntil('/');
if (command == "analog") {
analogCommand(client);
}
}
void analogCommand(BridgeClient client) {
pin = client.parseInt();
if (client.read() == '/') {
value = client.parseInt();
client.println("always use pin 5");
}
}