mirror of
https://github.com/esp8266/Arduino.git
synced 2025-07-30 16:24:09 +03:00
Updating Firmata (to r62 of their repository).
Changes include (according to Paul Stoffregen): "1: Hardware abstraction layer to support Arduino Mega, Teensy and Sanguino. 2: Extended analog message, to facilitate using PWM and Servo above pin 15. 3: Capability queries (alpha), to allow automatic discovery of any board's features."
This commit is contained in:
@ -4,12 +4,14 @@
|
||||
*/
|
||||
#include <Firmata.h>
|
||||
|
||||
byte analogPin;
|
||||
byte analogPin = 0;
|
||||
|
||||
void analogWriteCallback(byte pin, int value)
|
||||
{
|
||||
pinMode(pin,OUTPUT);
|
||||
analogWrite(pin, value);
|
||||
if (IS_PIN_PWM(pin)) {
|
||||
pinMode(PIN_TO_DIGITAL(pin), OUTPUT);
|
||||
analogWrite(PIN_TO_PWM(pin), value);
|
||||
}
|
||||
}
|
||||
|
||||
void setup()
|
||||
@ -24,9 +26,10 @@ void loop()
|
||||
while(Firmata.available()) {
|
||||
Firmata.processInput();
|
||||
}
|
||||
for(analogPin = 0; analogPin < TOTAL_ANALOG_PINS; analogPin++) {
|
||||
Firmata.sendAnalog(analogPin, analogRead(analogPin));
|
||||
}
|
||||
// do one analogRead per loop, so if PC is sending a lot of
|
||||
// analog write messages, we will only delay 1 analogRead
|
||||
Firmata.sendAnalog(analogPin, analogRead(analogPin));
|
||||
analogPin = analogPin + 1;
|
||||
if (analogPin >= TOTAL_ANALOG_PINS) analogPin = 0;
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user