Go Down

Topic: Send PWM value to Arduino pin from ESP8266 use Firmata (Read 208 times) previous topic - next topic

m4u_hoahoctro

Im using ESP8266 as firmata master and UNO as client, they communicate via TX RX pin

I refered FirmataMashaller to control UNO pin via sendPinMode and sendDigital, but how to send Analog value ?, i tried sendAnalog(9,255) and some other values but my led seems not fade.

Hope you helps, thanks. :)

Code: [Select]
#include <Boards.h>
#include <Firmata.h>
#include <FirmataConstants.h>
#include <FirmataDefines.h>
#include <FirmataMarshaller.h>
#include <FirmataParser.h>

firmata::FirmataMarshaller marshaller;

void setup() {
    Serial.begin(57600);
    marshaller.begin(Serial);
    marshaller.sendPinMode(13, OUTPUT);
    marshaller.sendPinMode(9, OUTPUT);
}

void loop () {
    marshaller.sendDigital(13, HIGH);
    marshaller.sendDigital(9, 1);
    delay(200);
    marshaller.sendDigital(13, LOW);
    marshaller.sendDigital(9, 0);
    delay(200);

    for (int fadeValue = 0 ; fadeValue <= 255; fadeValue += 5) {
    marshaller.sendAnalog(9, fadeValue);
    delay(30);
    }

    for (int fadeValue = 255 ; fadeValue >= 0; fadeValue -= 5) {
    marshaller.sendAnalog(9, fadeValue);
    delay(30);
    }
}

Go Up