Skip to content

Instantly share code, notes, and snippets.

@jywarren
Created December 8, 2011 17:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jywarren/1447660 to your computer and use it in GitHub Desktop.
Save jywarren/1447660 to your computer and use it in GitHub Desktop.
BlinkM MaxM RGB color from a knob
/*
* BlinkKnobHue -- Example of how to use a pot to set BlinkM hue
*
*
* For more info on how to use pots and analog inputs see:
* http://www.arduino.cc/en/Tutorial/AnalogInput
*
* BlinkM connections to Arduino
* PWR - -- gnd -- black -- Gnd
* PWR + -- +5V -- red -- 5V
* I2C d -- SDA -- green -- Analog In 4
* I2C c -- SCK -- blue -- Analog In 5
*
* Note: This sketch sends to the I2C "broadcast" address of 0,
* so all BlinkMs on the I2C bus will respond.
*/
#include "Wire.h"
#include "BlinkM_funcs.h"
const int blinkm_addr = 0;
const int hue_pot_pin = 0;
void setup()
{
Serial.begin(19200);
BlinkM_beginWithPower();
BlinkM_stopScript(blinkm_addr); // turn off startup script
Serial.println("BlinkMKnobHue ready");
}
void loop()
{
// read the hue pot, values range from 0-1023, blinkm's 0-255, thus /4
int hue_val = map(analogRead(hue_pot_pin),0,1023,0,(255*0.65)); // reduce color range to red...blue, exclude purples
Serial.println(hue_val);
// set blinkms with hue; brightness & saturation is max
BlinkM_fadeToHSB( blinkm_addr, hue_val, 255, 255 );
delay(50); // wait a bit because we don't need to go fast
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment