Go Down

Topic: combineing blink and bridge example to make a PWM (Read 338 times) previous topic - next topic


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

Code: [Select]
#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() {
unsigned long currentmillies = millis();

void loop() {
  BridgeClient client = server.accept();
  if (client) {
  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") {
void analogCommand(BridgeClient client) {
  pin = client.parseInt();
  if (client.read() == '/') {
    value = client.parseInt();
    client.println("always use pin 5");


This appears to be a duplicate of this post.

I wrote a detailed response in this reply. Your message above is time stamped about 10 minutes after my post. Is it safe to assume that I posted that while you were typing the above post, and you didn't see my reply?


Ya sorry I diden't see your response till today thank you for your help.

Go Up