This is something done as an extra for the Beyond the Phone Design Challenge.
For those interested, it was sponsored by Wurth and my conversations with sleuz was the deciding factor to apply.
I had heard that someone was rather interested in beer, and since we had these interesting taps that featured an illuminated circle, it made sense for me to call in a favour to get my hands on one.
The originals have a rather crude tungsten lamp and I imagine are a right pain to replace.
Sadly my tap didn't have the lamp, but there is not much thickness and as I understand it was low voltage.
My first idea was to create something that would illuminate both sides, using a led ring both sides, but it quickly became obvious that it was easier to concentrate on one side.
The decision to use neopixels was also made allowing colour changing and brightness.
To keep with the wireless theme, I used a battery and wireless charging.
A slight change to the design was made for a second Hall Effect switch for the brightness control.
Settings were stored in the EEPROM and the digispark has a modified bootloader to remove the 5 sec startup delay.
The items were stuck to a piece of mylar cut to fit within the circle, and a generous amount of double sided tape ensured they would behave themselves.
In real life these taps have refrigerant piped thru and the body is usually solid ice, so heat wouldn't be the issue if it was used in real life.
stolen from http://www.andale.com.au/glycol-beer-system/
Adafruit supplied the charger/battery management and the unit was turned toward the rear to allow it to be viewed more easily.
This gives an idea of some of the colours and the video shows it cycling between colours.
OFF WHITE BLUE
GREEN RED MIXED
The code is attached for anyone wanting to replicate it
/* Illuminated Beer Tap controller created for the "Beyond the Phone Challenge". Pin connections Digi tiny85 P0 (5)= P1 (6)= On board LED (Rev A) P2 (7)= NeoPixel P3 (2)= Hall Effect (Colour change) P4 (3)= Hall Effect (Brightness change) P5 (1)= EEPROM.write(1, Brightness); // Write it to EEPROM Created by Mark Beckett Version 0.1 Initial Code started June 2014 0.2 9 Sept 2014 Change to include Brightness and install in ATtiny85 --------------------------------------------------- To Do : */ // NeoPixel #include <adafruit_neopixel.h> #include #define PIN 2 //neopixel connected to P2 // Inputs const byte ButtonColour = 3; const byte ButtonBright = 4; // General long LastButtonCheck = 0; int ChangeTime = 25; int Brightness = 5; //setting for the Brightness // State Flags boolean setColour =0; // used to decide if colour change is happening boolean SetBright =0; // used to decide if set Brightness is happening boolean ButtonStateColour = 0; // boolean to store last change boolean ButtonStateBright =0; // boolean to store last change byte ButtonCountColour = 0; byte ButtonCountBright = 0; // Parameter 1 = number of pixels in strip // Parameter 2 = Arduino pin number (most are valid) // Parameter 3 = pixel type flags, add together as needed: // NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs) // NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers) // NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products) // NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2) Adafruit_NeoPixel strip = Adafruit_NeoPixel(12, PIN, NEO_GRB + NEO_KHZ800); // IMPORTANT: To reduce NeoPixel burnout risk, add 1000 uF capacitor across // pixel power leads, add 300 - 500 Ohm resistor on first pixel's data input // and minimize distance between Arduino and first pixel. Avoid connecting // on a live circuit...if you must, connect GND first. void setup() { strip.begin(); strip.show(); // Initialize all pixels to 'off' Brightness = (EEPROM.read(1)); //read the value set. pinMode (ButtonColour, INPUT); digitalWrite (ButtonColour, HIGH); // internal pull-up pinMode (ButtonBright, INPUT); digitalWrite (ButtonBright, HIGH); // internal pull-up for (int i=0; i<12; i++) { strip.setPixelColor(i, 255, 255, 255); //initially white strip.show(); } strip.setBrightness(Brightness); strip.show(); } void loop() { Check_Buttons(); if (setColour == 1) { rainbow(75); // Calls the Rainbow routine with a 40mS delay } else { // stay doing nothing } if (SetBright == 1) { BrightAdj(30); // Calls the Rainbow routine with a 30mS delay } else { // stay doing nothing } } void Check_Buttons() /* This routine checks the timer (LastButtonCheck) and if necessary reads the button input If the button is detected, it waits unitl it counts it 10 times at the set time rate. This prevents button bounce from triggering and ensures the button is pressed. Once a valid button press has been detected, it starts a timer (ButtonPressTime), */ { if (millis() - LastButtonCheck > 5) // Reads button state every 5mS and then updates button counts { ButtonStateColour = digitalRead(ButtonColour); ButtonStateBright = digitalRead(ButtonBright); LastButtonCheck = millis(); if (ButtonStateColour == LOW) { ButtonCountColour ++; // Increment the Count by 1 if (ButtonCountColour > 5) // the button should be LOW for 5x5mS = 25mS { // Button has been pressed for longer than 25mS so its valid ButtonCountColour = 0; setColour =1; // Do something with the valid button press } } else // Button is HIGH { ButtonCountColour =0; // Reset the counter as the button has been released setColour =0; } if (ButtonStateBright == LOW) { ButtonCountBright ++; // Increment the Count by 1 if (ButtonCountBright > 5) // the button should be LOW for 5x5mS = 25mS { // Button has been pressed for longer than 25mS so its valid ButtonCountBright = 0; SetBright =1; // Do something with the valid button press } } else // Button is HIGH { ButtonCountBright =0; // Reset the counter as the button has been released SetBright =0; } } } // The user wishes to change colour void rainbow(uint8_t wait) { Check_Buttons(); uint16_t i, j; for(j=0; j<256; j++) { for(i=0; i<strip.numpixels(); i++)="" ="" <br=""> { strip.setPixelColor(i, Wheel((i+j) & 255)); } strip.show(); Check_Buttons(); delay(wait); if (setColour == 0) { break; //get out } } } uint32_t Wheel(byte WheelPos) { if(WheelPos < 85) { return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0); } else if(WheelPos < 170) { WheelPos -= 85; return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3); } else { WheelPos -= 170; return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3); } } void BrightAdj(uint8_t wait) { uint16_t j; for(j=10; j<256; j++) { Brightness = j; strip.setBrightness(Brightness); strip.show(); delay(wait); Check_Buttons(); if (SetBright == 0) { EEPROM.write(1, j); // Write it to EEPROM break; //get out } } }
Hopefully this gives someone some inspiration, or another use for neopixels.
Cheers
Mark
Links for some of the original post
Wireless Challenge .... Beer Tap (the other bit) -3
Wireless Challenge .... Beer Tap (the other bit) - 4 Assembly