Firmata - basic help ?

This is a program on my arduino using Firmata :

#include <Firmata.h>



void digitalWriteCallback(byte pin, int value)
{
    pinMode(pin,OUTPUT);
    digitalWrite(pin, value);
} 


void setup()
{
        Firmata.attach(ANALOG_MESSAGE, digitalWriteCallback);
        Firmata.begin(9600);
}

void loop()
{
     while(Firmata.available()) {
        Firmata.processInput();
    }
}

On the serial monitor I am typing this :

ANALOG_MESSAGE(13,1);

Which do nothing because its probably wrong.

  1. I could not find any example to do this simple thing from serial, all of them are using “Processing” .
  2. How would you implement if statement ? for example get on serial some if statement, check some analog input and do something ?

Are you sure your baud rate is 9600?

Yes I am sure..

OK usually you also need to call setFirmwareVersion before the begin just to ensure both side talk the same language. Are you sure the defaults are fine for you?

Also a bit confused about the naming convention for your callback - it’s for analog message and you call this digital in the name of the function

And of course if you try to type the commands in the serial console - did I get that right ? - then it won't work. The protocol is based on something similar to MIDI, you send command bytes

  1. I could not find any example to do this simple thing from serial, all of them are using "Processing" .

The library that processing uses converts the function calls to serial messages properly. Feel free to look at the code and perform the same conversion yourself.

Why do you think that "ANALOG_MESSAGE(13,1);" is ANYTHING like the proper message? Which Arduino have you lobotomized? On the 328 based Arduinos, pin 13 is NOT a PWM pin, so anything with analog in the name, using pin 13, does not make sense.

Where do you think you have told the Arduino that pin 13 is even an output pin?