Skip to content

Instantly share code, notes, and snippets.

@ricklon
Created July 5, 2017 20:33
Show Gist options
  • Save ricklon/4f3b00b446069dc406482b7d650e38d5 to your computer and use it in GitHub Desktop.
Save ricklon/4f3b00b446069dc406482b7d650e38d5 to your computer and use it in GitHub Desktop.
// #define IS_PIN_ANALOG(p) ((p) == 0 || ((p) >= 3 && (p) <= 13))
// #define PIN_TO_ANALOG(p) ((p) == 0 ? 0 : ((((p) >= 1 && (p) <= 11)) ? ((p) + 2) : (p)))
#include <Servo.h>
#include <Wire.h>
#include <Firmata.h>
void setup() {
pinMode(PIN_BTN1, INPUT);
Serial.begin(9600);
}
void loop() {
static uint8_t p1 = digitalRead(PIN_BTN1);
if (digitalRead(PIN_BTN1) != p1) {
p1 = digitalRead(PIN_BTN1);
if (p1 == HIGH) {
for (int ii = 0; ii < 21; ii += 1) {
Serial.printf("A%d, toPin: %d, isPinAnalog: %d\n",ii, PIN_TO_ANALOG(ii), IS_PIN_ANALOG(PIN_TO_ANALOG(ii)));
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment