Hardware Hump Day: Wheel-of-Lunch

Eliminate pesky decision-making with this randomized lunch picker!

“Where should we go for lunch?” It’s a simple question that’s often followed by lengthy debate---because making decisions is hard when you're hungry, and pretty much everything sounds delicious.

We hear this conversation all the time here at SparkFun. A few guys on my team grab lunch together every day, and they always pick the same few restaurants. Now, I know how harrowing the process of choosing a lunch restaurant can be, so I decided to make it all a little easier for my buddies. Meet Wheel-of-Lunch, an Arduino-controlled randomized lunch picker.

Wheel-of-Lunch turns on when you hit the momentary push button, which triggers a DC motor and an LED strip.

After a randomized delay, the motor and LEDs turn off, and the pin attached to the motor stops and points to the chosen restaurant.

alt text

Now the decision has been made for the group. No debating required!

If you too struggle with knowing where to get lunch, you can build your very own Wheel-of-Lunch to simplify your life. To get started, you will need the following products:

Arduino Pro Mini 328 - 5V/16MHz

DEV-11113
$10.95

Hobby Motor - Gear

ROB-11696
$2.10

DC Barrel Jack Adapter - Female

PRT-10288
$3.50

Tactile Button Assortment

COM-10302
$6.50

Resistor 10k Ohm 1/6th Watt PTH

COM-08374
$0.10

N-Channel MOSFET 60V 30A

COM-10213
Retired

LED RGB Strip - Addressable, Bare (1m)

COM-12025
Retired

This project has four main electrical components: a push button, a DC motor, an LED strip and, of course, a microcontroller. I used the Arduino Mini because of its small size. The following Fritzing diagram illustrates the circuit.

alt text

Having a hard time seeing the circuit? Click on the wiring diagram for a closer look.

Below is the code I used to execute this project. Please note that you will need to download the Adafruit NeoPixel Library. If you are unfamiliar with Arduino libraries, feel free to check out our tutorial.

//Wheel-of-Lunch by Melissa Felderman for SparkFun

#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
  #include <avr/power.h>
#endif

#define PIN 10

int pixNum = 18;

Adafruit_NeoPixel strip = Adafruit_NeoPixel(pixNum, PIN, NEO_GRB + NEO_KHZ800);

int motor = 7;
int button = 4;
int buttonVal;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  pinMode(motor, OUTPUT);
  pinMode(button, INPUT);

  strip.begin();
  strip.show();
}

void loop() {
  // put your main code here, to run repeatedly:
  buttonVal = digitalRead(button);
  Serial.println(buttonVal);

  if(buttonVal == 1){

    digitalWrite(motor, HIGH);
    rainbowCycle(random(0, 50000000));

    digitalWrite(motor, LOW);

  } 
  }





// Slightly different, this makes the rainbow equally distributed throughout
void rainbowCycle(uint8_t wait) {
  uint16_t i, j;

  for(j=0; j<256*5; j++) { // 5 cycles of all colors on wheel
    for(i=0; i< strip.numPixels(); i++) {
      strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
    }
    strip.show();
    delayMicroseconds(wait);

  }  for(i=0; i< strip.numPixels(); i++){
      strip.setPixelColor(i, strip.Color(0,0,0));
     strip.show();
   }
}


uint32_t Wheel(byte WheelPos) {
  WheelPos = 255 - WheelPos;
  if(WheelPos < 85) {
    return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
  }
  if(WheelPos < 170) {
    WheelPos -= 85;
    return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
  }
  WheelPos -= 170;
  return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
}

I used a 4" PVC pipe cap that I bought at the hardware store as the base of my enclosure. Inside, I have most of my circuit---with my LED strip glued around the inner edge. I drilled a small hole in the PVC pipe cap so that I could lead wires through there.

For the top of the enclosure, I used translucent acrylic on our laser cutter to cut the wheel and etch the restaurant logos. I darkened the logos with a black marker, which easily wipes off the non-etched surface. I also use some black acrylic to cut a tiny pointer that attaches to the motor head.

alt text

Picking a lunch spot has never been more fun!

What would your Wheel-Of-Lunch look like? Share your thoughts with us in the comments below!