19
Little Bee

2015.05.27│littleBits Arduino Code Test│NTUT Interaction Design│

  • Upload
    enyc

  • View
    41

  • Download
    4

Embed Size (px)

Citation preview

Little Bee

在手指上舞動的小翅膀

機械部分

準備材料

製作過程

製作過程

製作過程

製作過程

製作過程

LittleBits 部分

需要的模組

Battery+cable Power

Microphone ServoArduino

額外需要的物件

組裝後

Servo+翅膀Battery+cable—Power—Microphone—Arduino—Servo

Arduino 程式#include <Servo.h>

const int inPin = A0;

Servo myservo;

int sound;int pos = 0;

引入系統內部的 Servo.h 文件

建立唯讀參數

建立物件 Servo

宣告兩個變數類型為 int ( 整數 )

Arduino 程式void setup() {

pinMode(inPin, INPUT);

myservo.attach(9);

}

設定 pin 的位址與模式 (Mode)

設定 myservo 的位址

Arduino 程式void loop() {

if (sound > 600) {for(pos = 0; pos <= 180; pos +=

1){ myservo.write(pos); delay(15); }

for(pos = 180; pos>=0; pos-=1){

myservo.write(pos);delay(15); }

}else{myservo.write(0); }

sound = analogRead(inPin);}

成果

值得高興的小成果 !

值得高興的小成果 !