aboutsummaryrefslogtreecommitdiff
path: root/libraries/Firmata/examples/EchoString/EchoString.pde
blob: e5c4e6fe5dc970ebcc59d58752b49dddae9ead6f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/* This sketch accepts strings and raw sysex messages and echos them back.
 *
 * This example code is in the public domain.
 */
#include <Firmata.h>

byte analogPin;

void stringCallback(char *myString)
{
    Firmata.sendString(myString);
}


void sysexCallback(byte command, byte argc, byte*argv)
{
    Serial.write(START_SYSEX);
    Serial.write(command);
    for(byte i=0; i<argc; i++) {
        Serial.write(argv[i]);
    }
    Serial.write(END_SYSEX);
}

void setup()
{
    Firmata.setFirmwareVersion(0, 1);
    Firmata.attach(STRING_DATA, stringCallback);
    Firmata.attach(START_SYSEX, sysexCallback);
    Firmata.begin(57600);
}

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