#include #include Servo myservo; // create servo object to control a servo byte analogPin; //firmata example int potPin = 2; // analog pin used to connect the potentiometer int val; // variable to read the value from the analog pin //firmata example void analogWriteCallback(byte pin, int value) { pinMode(pin,OUTPUT); analogWrite(pin, value); } void setup() { myservo.attach(9); // attaches the servo on pin 9 to the servo object //firmata example Firmata.setFirmwareVersion(0, 1); Firmata.attach(ANALOG_MESSAGE, analogWriteCallback); Firmata.begin(); } void loop() { val = analogRead(potPin); // reads the value of the potentiometer (value between 0 and 1023) val = map(val, 0, 1023, 0, 179); // scale it to use it with the servo (value between 0 and 180) myservo.write(val); // sets the servo position according to the scaled value delay(15); // waits for the servo to get there //firmata example while(Firmata.available()) { Firmata.processInput(); } for(analogPin = 0; analogPin < TOTAL_ANALOG_PINS; analogPin++) { Firmata.sendAnalog(analogPin, analogRead(analogPin)); } } /* int potPin = 2; // select the input pin for the potentiometer int ledPin = 13; // select the pin for the LED int val = 0; // variable to store the value coming from the sensor void setup() { pinMode(ledPin, OUTPUT); // declare the ledPin as an OUTPUT } void loop() { val = analogRead(potPin); // read the value from the sensor digitalWrite(ledPin, HIGH); // turn the ledPin on delay(val); // stop the program for some time digitalWrite(ledPin, LOW); // turn the ledPin off delay(val); // stop the program for some time } */