Draw

作品簡介:

用途-此作品是用於抽誰出去買飯或買飲料。

以Arduino的LED燈代替抽籤,按一下按鈕,亮哪個LED燈便代表是誰要負責去買。而如果沒有LED燈亮的話,便代表就別買了。如果想買就再抽一次。

動機-有時候待在家常常大家都不想去買飯買飲料,所以想做一個可以抽誰要負責去買的機器

材料清單:
-Arduino 麵包板 x1

-LED燈 x6

-大按鈕 x1

-公對公電線 x15

-黃色電阻 x7

-連接線 x1

Introduction:

Usage - This machine is for people to draw about who should go out to buy food or buy drinks.

Draw is replace with the Arduino LED light. Press the button, the person's name with LED lighting up responsible for buying food or buying drinks. If no LED light up, then nobody should go and buy food and drink. If all of you want to choose a person to buy, you can take another roll.

Motivation - Sometimes when me and my family stay at home, we don't want to buy food and buy drinks, so we want to have a machine that you can take to buy.

Materials:
-Arduino breadboard x1

-LED light x6

- Large button x1

- Wire x15

- Yellow resistor x7

Step 1: Connect Five LED Circuit (將LED燈的電路接好,接五個)

圖片來源:http://drho.club/2017/12/arduino-unit-2/

Step 2: Connect the Button's Circuit (接按鈕的電路)

圖片來源:Arduino連接開關按鍵電路示意圖

Step 3: Complete Circuit (pic) 完整電路圖

Step 4: Paste the Code (貼上程式)

https://create.arduino.cc/editor/candyliu/b7c8fd93-3a14-49e1-aedc-0b671b930e19/preview

#define DEBUG 0
int first = 2;
int second = 3;
int third = 4;
int fourth = 5;
int fifth = 6;
int sixth = 7;
//set all LEDs
int button = 12; //button pin code
int pressed = 0;
void setup() {
  for (int i=first; i<=sixth; i++) {
    pinMode(i, OUTPUT);
  }
  pinMode(button, INPUT);
  
  randomSeed(analogRead(0));
  #ifdef DEBUG
    Serial.begin(9600);
  #endif
}
void buildUpTension() {
  for (int i=first; i<=sixth; i++) {
    if (i!=first) {
      digitalWrite(i-1, LOW);
    }
    digitalWrite(i, HIGH);
    delay(100);
  }
  for (int i=sixth; i>=first; i--) {
    if (i!=sixth) {
      digitalWrite(i+1, LOW);
    }
    digitalWrite(i, HIGH);
    delay(100);
  }
}
void showNumber(int number) {
   if (number == 2) {
  digitalWrite(first, HIGH);
  }
  if (number == 3) {
    digitalWrite(second, HIGH);
  }
  if (number == 4) {
    digitalWrite(third, HIGH);    
  }
  if (number == 5) {
    digitalWrite(fourth, HIGH);    
  }
  if (number == 6) {
    digitalWrite(fifth, HIGH);    
  }
  if (number == 7) {
    digitalWrite(sixth, HIGH);    
  }
}
int throwDice() {
  int randNumber = random(1,7);
  
  #ifdef DEBUG
    Serial.println(randNumber);
  #endif
  
  return randNumber;
}
void loop() {
  pressed = digitalRead(button);
  if (pressed == HIGH) {
    // remove previous number
    
    buildUpTension();
    int thrownNumber = throwDice();
    showNumber(thrownNumber);
  } 
}

Step 5: Wrap Up 貼包裝(以下包裝步驟)

Step 6: Take a Paper Bag 步驟1: 拿一個紙袋

Step 7: Cut It in Half 步驟2:將紙袋剪一半

Step 8: Cut a Piece of Paper and Stick It Onto the Paper Bag 步驟3:剪一片紙袋貼上減一半的紙袋

Step 9: Cut a Hole 步驟4:剪一個放連接線的口

Step 10: Place the Breadboard in and Stick the Names on 步驟5:將麵包板放入並貼上名字便完成了

Step 11: Upload the Program and You're Done上傳程式便可使用了

Step 12: Final Product 成品

Step 13: Video 成品影片

Share

    Recommendations

    • 1 Hour Challenge

      1 Hour Challenge
    • Classroom Science Contest

      Classroom Science Contest
    • Frozen Treats Challenge

      Frozen Treats Challenge

    Discussions