Skip to content

Instantly share code, notes, and snippets.

@maciejmatu
Last active May 16, 2019 12:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maciejmatu/1a364e2f4cf019ad5e10ad767a7dd93e to your computer and use it in GitHub Desktop.
Save maciejmatu/1a364e2f4cf019ad5e10ad767a7dd93e to your computer and use it in GitHub Desktop.

Simplified lamp software algorithm

  1. Define constants for pins e.g. #define LED_RED 9
  2. Instantiate hueRotart, saturationRotary and bluetooth software serial
  3. Run void setup() { ... }
    1. Run startup sequence R => G => B => GB => RB => RG => RGB (helps with checking if colors are hooked up correctly
    2. Begin listening for bluetooth serial on 9600 rate
    3. Begin listening for hueRotatary and saturationRotary
    4. Setup brightness controls pins VALUE_INCREASE and VALUE_DECREASE to INPUT_PULLUP to avoid faulty readings
  4. Run void loop() { ... } in loop
    1. If brightness changed, update the lampColor hsv variable
    2. If hue changed, update the lampColor hsv variable
    3. If saturation changed, update the lampColor hsv variable
    4. Update actual lamp color with analogWrite() based on previously set hue, saturation, and brightness in lampColor variable.
    5. Re-run the loop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment