Share this post!
Share on FacebookShare on Google+Tweet about this on TwitterEmail this to someone

Poin2 Lab. is located in the heart of Seoul – Gangnam area, well known for “Gangnam Style”. Do you know psy? There are so many places to eat, just sooooo many, so it’s actually hard to decide what to eat for lunch. To solve this issue, I made a small decision maker using Arduino Nano, 6 LEDs, and a switch, so the device will randomly choose 1 out of 6 choices when the reset button is pressed. I tried to make things a little fancier than previous projects, so there were some soldering involved. However, you can do it simply on a breadboard and probably cover it up somehow to make it look much fancier than mine.

 

Things you need:
Arduino Nano x 1
LED (Whatever colors you want) x 6
Switch Button x 1
Wires

 

Hardware Connection:
hwc
Connect LEDs to Digital GPIO 2-7 through 330ohm resistors, a switch between Reset and Ground, and you are good to go!

a20150727_145331
I had a plastic case laying around the office, so decided to give it a new life as a decision maker.

a20150727_155945
Drilling holes with a hand drill bit.

a20150728_111035
Soldering components (a little messy, I know.. 😉 )

a20150728_111045
The end product! Now it’s time to program Arduino.

 

Programming Arduino

The above code basically creates a random number, then divides it by 6, take the remainder and add 2 because I decided to use digital pins 2-7 for LEDs. The rest of code is just to make the device a little more fun, making the LEDs to turn on sequentially until the result is reached.

Every morning as we come to the office, we’d put down whatever we want to eat on a piece of paper on first-come, first-served base, and have this little decision maker choose our lunch. The first day went by very smoothly, with no one complaining about the menu. let’s wait and see how well it will serve its purpose 😀
a20150729_104847

 

Simple decision maker using Arduino
Share this post!
Share on FacebookShare on Google+Tweet about this on TwitterEmail this to someone
Tagged on:                 

14 thoughts on “Simple decision maker using Arduino

  • July 29, 2015 at 5:23 pm
    Permalink

    헐.. 손으로 뚫은 거였어요? 대애박;; 몰랐음 @.@

    Reply
    • July 29, 2015 at 5:46 pm
      Permalink

      ㅋㅋㅋ 별로 어려운거 아니에요

      Reply
  • March 22, 2016 at 1:04 pm
    Permalink

    Can i use more than just 6 led i would like to use 8 or 10 led.

    Reply
    • March 22, 2016 at 1:07 pm
      Permalink

      Sure, you can have as many LEDs as the number of output pins left. If you need even more, you can use LED matrix.

      Reply
      • March 23, 2016 at 1:43 am
        Permalink

        how do I add the other led to the code just add it to the pinmode output with pin number.
        pinMode(2, OUTPUT);
        pinMode(3, OUTPUT);
        pinMode(4, OUTPUT);
        pinMode(5, OUTPUT);
        pinMode(6, OUTPUT);
        pinMode(7, OUTPUT);

        Reply
        • March 24, 2016 at 11:50 am
          Permalink

          That’s correct. Also, you need to modify few numbers accordingly to the number of LEDs you will be using. You could make things easier by defining number of LEDs in the beginning of the code and changing below numbers to a variable.

          They will be
          “6” in int choice = menu%6 +2;
          “6” in int remainder = (menu – ledStart)%6 + 2; (there are 3 of these in the code)
          “7” in int lastRound=7; to LED numbers + 1

          “8” to LED numbers + 2, 9 to LED numbers + 3 in the code below.
          for(int j=2; j<8; j++){
          digitalWrite(9-j, 1);
          delay(interval);
          }
          for(int j=2; j<8; j++){
          digitalWrite(9-j,0);
          delay(interval);

          Reply
          • March 24, 2016 at 4:26 pm
            Permalink

            I know nothing about this code stuff but just a very little…all i want is 8 LEDs.thanks for your help…

  • March 28, 2016 at 12:29 pm
    Permalink

    YC……..
    Thanks for all your help…I got it working with 10 LEDs…it is sooooooooooooooooo AWSOME…THANKS AGAIN.

    Reply
    • March 28, 2016 at 12:35 pm
      Permalink

      That is so great to hear 🙂 Enjoy!

      Reply
  • November 26, 2016 at 4:54 pm
    Permalink

    is there any way to modify the code to just blink the leds in your pattern all the time… i love the pattern you have them blinking and would like to use the pattern you have setup on the just for blinking les….

    Reply
    • November 28, 2016 at 10:45 am
      Permalink

      Hello Jim,

      You can put the part of the code starting with “while” of the setup{} into the loop{}, then it will repeat itself 🙂

      Reply
      • November 28, 2016 at 5:16 pm
        Permalink

        im not sure what you mean…..like i said early im not that good yet im still learning. i dont have much time to spend on this stuff right now because of work..

        Reply
        • December 6, 2016 at 11:39 am
          Permalink

          Should be something like this:


          int menu;

          void setup() {
          Serial.begin(9600);
          // set the digital pin as output:
          pinMode(2, OUTPUT);
          pinMode(3, OUTPUT);
          pinMode(4, OUTPUT);
          pinMode(5, OUTPUT);
          pinMode(6, OUTPUT);
          pinMode(7, OUTPUT);

          randomSeed(((analogRead(A0)+53)*(analogRead(A1)+15)*(analogRead(A2)*29))/64);//make sure random number is actually random everytime Arduino is reset
          menu = random (181,241); //random number between 181 & 240
          int ledStart=0;
          int initDelay = 65;
          int choice = menu%6+2; //result is already set here, the rest of code is all about LED behavior

          Serial.println((analogRead(A0)+53)*(analogRead(A1)+15)*(analogRead(A2)*29));
          Serial.println(menu);
          Serial.println(choice);

          }

          void loop() //loop is empty so the program will run only once after reset
          {
          //Initialize LEDs
          circle(20,5); //5 rounds of 20ms LED circle
          circle(30,4); //4 rounds of 30ms LED circle
          circle(40,2);

          //LED circles around until it reaches the random number
          while (ledStart+100 < = menu){ int remainder = (menu - ledStart)%6 + 2; oneway(15,remainder); ledStart++; } //little bit slower while (ledStart+30 <= menu){ int remainder=(menu-ledStart)%6 + 2; oneway(55,remainder); ledStart++; } //interval is increased as it reaches the result while(ledStart<=menu){ int remainder=(menu-ledStart)%6 + 2; oneway(initDelay,remainder); ledStart++; initDelay=initDelay+10; } // Dealing with last few numbers to reach preset result if (ledStart > menu){
          int lastRound=7;
          while(lastRound>choice){
          oneway(initDelay,lastRound);
          lastRound--;
          initDelay=initDelay+10;
          }
          delay(100);
          digitalWrite(choice,1);
          }
          }

          //Turn on all LEDs in order, then turn them off in order
          void circle(int interval, int times)
          {
          for(int i=0; i

          Reply
          • December 8, 2016 at 7:23 am
            Permalink

            Ok thank you very much..

Leave a Reply

Your email address will not be published. Required fields are marked *