Software apps and online services
I found an old SODAQ Mbili board and whipped up a demo with a couple of Seeed Grove modules—a potentiometer that dims an LED. The board is discontinued, but if I could happen across one in an old electronics trove, perhaps someone else will too, and I hope they appreciate this. :)The Circuit
Pretty simple: plug the potentiometer module into socket A0, the LED module into D4, and the whole board into your computer with a USB Mini cable.
The LED didn't light up at first, so I had to turn down that module's variable resistor, by turning the mini knob with a screwdriver.
The Grove connectors on the Mbili are a little confusing, since each is labeled with two pin numbers. Just pick the ones that correspond to these numbers, and you're good.The Code
I had to install the board definitions for the SODAQ boards in Arduino: http://support.sodaq.com/sodaq-one/mbili/
Then, I mashed together code from two Arduino examples – AnalogReadSerial and Fading – with a map() function. The potentiometer gives a 0-1023 value, and the LED takes a 0-255 brightness value, so map() scales the knob output down to match the LED's range.
int fadeValue = analogRead(0); fadeValue = map(fadeValue, 0, 1023, 0, 255); analogWrite(ledPin, fadeValue);
I also left in the Serial code, which prints the current potentiometer reading to the Arduino IDE's serial monitor.
Check out the full sketch in the Code section below :)Use It
Now, twist the knob, and watch the LED fade brighter and dimmer. Woooooo, SO MUCH FUN
(But seriously, I hope this workflow is easy for you to adapt to whatever other projects you're building. Hack on!)