summaryrefslogtreecommitdiff
path: root/Arduino/ServoFirmata_9_11/ServoFirmata_9_11.pde
blob: 1119045c51b5c895dd88bb98dc6d245c812774b5 (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
/* This firmware supports as many servos as possible using the Servo" library 
 * included in Arduino 0012
 *
 * TODO add message to configure minPulse/maxPulse/degrees
 *
 * This example code is in the public domain.
 */
 
#include <Firmata.h>
#include <Servo.h>

Servo servo9;
Servo servo11;

void analogWriteCallback(byte pin, int value)
{
    if(pin == 9)
      servo9.write(value);
    if(pin == 11)
      servo11.write(value);
}

void setup() 
{
    Firmata.setFirmwareVersion(0, 2);
    Firmata.attach(ANALOG_MESSAGE, analogWriteCallback);

    servo9.attach(9);
    servo11.attach(11);
   
    Firmata.begin(57600);
}

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