aboutsummaryrefslogtreecommitdiff
path: root/libraries/Firmata/examples/ServoFirmata/ServoFirmata.pde
blob: a3c609c83895522f5c30ead5febf2694dc816410 (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 servo10;

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

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

    servo9.attach(9);
    servo10.attach(10);
   
    Firmata.begin();
}

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