Hi all,
i'm trying to write what I thought was a simple code for Arduino to write a digital output as a loop using Firmata protocol. I have a software that is sending digital output to Arduino (pin 4) and I want to run a loop (for example blinking internal LED) every time the pin 4 receives inputs. Attached the Arduino Sketch I wrote (without success).
#include <Firmata.h>
byte input = 4;
byte stim_pin = 13;
void setup() {
Firmata.setFirmwareVersion (FIRMATA_MAJOR_VERSION, FIRMATA_MINOR_VERSION);
Firmata.attach (DIGITAL_MESSAGE, digitalWriteCallback);
Firmata.begin (57600);
pinMode (input, INPUT);
pinMode (stim_pin, OUTPUT);
digitalWrite (stim_pin, LOW);
}
void loop() {
while (Firmata.available()) {
Firmata.processInput();
}
}
void digitalWriteCallback (byte pin, int value) {
if (pin == input) {
digitalWrite (stim_pin, HIGH);
delay (20);
digitalWrite (stim_pin, LOW);
delay (30);
}
else {
digitalWrite (stim_pin, LOW);
}
}
There is any way to activate a specific pin (loop High - low) on Arduino running firmata when a specific pin on the board is activated (High)?