Orm
July 29, 2014, 5:19pm
1
Hello!
Well, I must be looking in the wrong places, but I cannot seem to find a good resource on using rotary encoders (Pushbutton type specifically) with the spark core.
Surely there must be something, and I am just not looking right?
Dave
July 29, 2014, 5:58pm
2
Hi @Orm ,
I think this version is not interrupt driven or anything fancy, but this lamp project uses a rotary encoder:
/*
spark-torch.ino is a program that runs as firmware for the CloudLamp. It uses an array with brightness values to have a dimming curve approximated
as (e^x - 1) / 1.578. It also has a spark function "turnTo" that allows for remote dimmability. The light engine is two Adafruit Neopixel LED boards.
*/
// This #include statement was automatically added by the Spark IDE.
#include "neopixel/neopixel.h"
#include "math.h"
#define NEOPIXEL_PIN A0 //data pin for the neopixel LEDs
#define NEOPIXEL_COUNT 32 //# of LEDs
#define NEOPIXEL_TYPE WS2812B //type of LEDs
double lightState = 0; //variable for keeping track of the brightness value for the lamp.
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NEOPIXEL_COUNT, NEOPIXEL_PIN, NEOPIXEL_TYPE); //setup neopixel strip
uint32_t color = strip.Color(255, 205, 152); //set color of LEDs to imitate tungsten light via RGB
int top = D0; // Define encoder pin A (The top pin)
int bottom = D1;// Define encoder pin B (The bottom pin)
This file has been truncated. show original
Thanks!
David