總網頁瀏覽量

2012年6月23日 星期六

Arduino / motoduino controls 7 Servos + 1 Stepper Motor (步進馬達)

做了一個簡單實驗, 利用Arduino/Motoduino控制七顆伺服馬達(手上只有七顆)和一顆步進馬達(2-Phase)運轉,運轉還算順暢! 主要利用 I/O Expansion Shield疊在motoduino上,除了馬達電線容易接線外,還可讓七顆伺服馬達吃外部電源.DIY material (材料):
1. Motoduino (Arduino + L293D motor driver)
2. I/O Expansion shield
3. Servo motor (伺服馬達) x 7 
4. Stepper Motor(步進馬達 二相四線)  x 1
5. 9V Battery x 2


接線圖

接線圖

                                                              I/O Expansion Shield V5




Arduino Sketch: (有興趣網友可以把重複程式建立function來呼叫)



#include <Stepper.h>
#include <Servo.h>

Servo servo12;          // Define servo12
Servo servo11;          // Define servo11
Servo servo10;          // Define servo10
Servo servo9;          // Define servo9
Servo servo4;          // Define servo4
Servo servo3;          // Define servo3
Servo servo2;          // Define servo2

const int stepsPerRevolution = 200;  // change this to fit the number of steps per revolution                                 // for your motor
const int Motor_E1 = 5; // digital pin 5 of Arduino (PWM)  
const int Motor_E2 = 6;  // digital pin 6 of Arduino (PWM)
const int Motor_M1 = 7;     // digital pin 7 of Arduino
const int Motor_M2 = 8;    // digital pin 8 of Arduino
   
Stepper myStepper(stepsPerRevolution, Motor_M1, Motor_M2);          
int pos = 0;

void setup() {
  // set the speed at 60 rpm:
  myStepper.setSpeed(60);
  // initialize the serial port:
  Serial.begin(9600);
  pinMode(Motor_M1, OUTPUT);
  pinMode(Motor_M2, OUTPUT);

  digitalWrite( Motor_E1, HIGH);  // speed control
  digitalWrite( Motor_E2, HIGH);  // speed control

  servo12.attach(12);
  servo11.attach(11);
  servo10.attach(10);
  servo9.attach(9);
  servo4.attach(4);
  servo3.attach(3);
  servo2.attach(2);

}

void loop() {
  // step one revolution  in one direction:
//   Serial.println("clockwise");
  myStepper.step(200);
  delay(500);

for(pos = 0; pos < 180; pos += 1)  // goes from 0 degrees to 180 degrees
  {                                  // in steps of 1 degree
    servo12.write(pos);              // tell servo to go to position in variable 'pos'
    servo11.write(pos);              // tell servo to go to position in variable 'pos'
    servo10.write(pos);              // tell servo to go to position in variable 'pos'
    servo9.write(pos);              // tell servo to go to position in variable 'pos'
    servo4.write(pos);              // tell servo to go to position in variable 'pos'
    servo3.write(pos);              // tell servo to go to position in variable 'pos'
    servo2.write(pos);              // tell servo to go to position in variable 'pos'
    delay(10);                       // waits 15ms for the servo to reach the position
  }
  for(pos = 180; pos>=1; pos-=1)     // goes from 180 degrees to 0 degrees
  {                              
    servo12.write(pos);              // tell servo to go to position in variable 'pos'
    servo11.write(pos);              // tell servo to go to position in variable 'pos'
    servo10.write(pos);              // tell servo to go to position in variable 'pos'
    servo9.write(pos);              // tell servo to go to position in variable 'pos'
    servo4.write(pos);              // tell servo to go to position in variable 'pos'
    servo3.write(pos);              // tell servo to go to position in variable 'pos'
    servo2.write(pos);              // tell servo to go to position in variable 'pos'
    delay(10);                       // waits 15ms for the servo to reach the position
  }
for(pos = 0; pos < 180; pos += 1)  // goes from 0 degrees to 180 degrees
  {                                  // in steps of 1 degree
    servo12.write(pos);              // tell servo to go to position in variable 'pos'
    servo11.write(pos);              // tell servo to go to position in variable 'pos'
    servo10.write(pos);              // tell servo to go to position in variable 'pos'
    servo9.write(pos);              // tell servo to go to position in variable 'pos'
    servo4.write(pos);              // tell servo to go to position in variable 'pos'
    servo3.write(pos);              // tell servo to go to position in variable 'pos'
    servo2.write(pos);              // tell servo to go to position in variable 'pos'
    delay(10);                       // waits 15ms for the servo to reach the position
  }
  for(pos = 180; pos>=1; pos-=1)     // goes from 180 degrees to 0 degrees
  {                              
    servo12.write(pos);              // tell servo to go to position in variable 'pos'
    servo11.write(pos);              // tell servo to go to position in variable 'pos'
    servo10.write(pos);              // tell servo to go to position in variable 'pos'
    servo9.write(pos);              // tell servo to go to position in variable 'pos'
    servo4.write(pos);              // tell servo to go to position in variable 'pos'
    servo3.write(pos);              // tell servo to go to position in variable 'pos'
    servo2.write(pos);              // tell servo to go to position in variable 'pos'
    delay(10);                       // waits 10ms for the servo to reach the position
  } `
  for(pos = 0; pos < 180; pos += 1){  // goes from 0 degrees to 180 degrees
    servo12.write(pos);    // tell servo to go to position in variable 'pos'
    delay(10);
  }
  for(pos = 0; pos < 180; pos += 1){  // goes from 0 degrees to 180 degrees
    servo11.write(pos);              // tell servo to go to position in variable 'pos'
    delay(10);
  }
  for(pos = 0; pos < 180; pos += 1){  // goes from 0 degrees to 180 degrees
    servo10.write(pos);              // tell servo to go to position in variable 'pos'
    delay(10);
  }
  for(pos = 0; pos < 180; pos += 1){  // goes from 0 degrees to 180 degrees
    servo9.write(pos);              // tell servo to go to position in variable 'pos'
    delay(10);
  }
  for(pos = 0; pos < 180; pos += 1) { // goes from 0 degrees to 180 degrees
    servo4.write(pos);              // tell servo to go to position in variable 'pos'
    delay(10);
  }
  for(pos = 0; pos < 180; pos += 1) { // goes from 0 degrees to 180 degrees
    servo3.write(pos);              // tell servo to go to position in variable 'pos'
    delay(10);
  }
  for(pos = 0; pos < 180; pos += 1) { // goes from 0 degrees to 180 degrees
    servo2.write(pos);              // tell servo to go to position in variable 'pos'
    delay(10);
  }

  for(pos = 180; pos>=1; pos-=1) {    // goes from 180 degrees to 0 degrees
    servo2.write(pos);              // tell servo to go to position in variable 'pos'
    delay(10);
  }
  for(pos = 180; pos>=1; pos-=1) {    // goes from 180 degrees to 0 degrees
    servo3.write(pos);              // tell servo to go to position in variable 'pos'
    delay(10);
  }
  for(pos = 180; pos>=1; pos-=1) {    // goes from 180 degrees to 0 degrees
    servo4.write(pos);              // tell servo to go to position in variable 'pos'
    delay(10);
  }
  for(pos = 180; pos>=1; pos-=1) {    // goes from 180 degrees to 0 degrees
    servo9.write(pos);              // tell servo to go to position in variable 'pos'
    delay(10);
  }
  for(pos = 180; pos>=1; pos-=1) {    // goes from 180 degrees to 0 degrees
    servo10.write(pos);              // tell servo to go to position in variable 'pos'
    delay(10);
  }
  for(pos = 180; pos>=1; pos-=1) {    // goes from 180 degrees to 0 degrees
    servo11.write(pos);              // tell servo to go to position in variable 'pos'
    delay(10);
  }
  for(pos = 180; pos>=1; pos-=1) {    // goes from 180 degrees to 0 degrees
    servo12.write(pos);              // tell servo to go to position in variable 'pos'
    delay(10);
  }

  for(pos = 0; pos < 180; pos+=1) {    // goes from 0 degrees to 180 degrees
    servo12.write(pos);              // tell servo to go to position in variable 'pos'
    servo11.write(pos);              // tell servo to go to position in variable 'pos'
    delay(5);
  }

  for(pos = 180; pos >=1; pos-=1) {    // goes from 180 degrees to 0 degrees
    servo12.write(pos);
    servo11.write(pos);              // tell servo to go to position in variable 'pos'
    delay(5);
  }
   myStepper.step(-200);
  delay(500);
}






Video:  http://www.youtube.com/watch?v=rB-noWhgbXM&list=UU6aKpj71jLKYABYLr3Wbpuw&index=1&feature=plcp



更多影片請看: http://www.youtube.com/user/sinocgtchen
部落格 : http://sinocgtchen.blogspot.com
Motoduino資訊: http://motoduino.com


2012年4月24日 星期二

Color Shield Remote Control = Motoduino / Arduino + Bluetooth + Android + RGB LED 8x8

Arduino Color Shield 加上 RGB LED 很適合做學生專題及LED基本學習, Color shield 是Colorduino的簡易版,主要差在color shield無法繼續串接下去,只有8x8 RGB LED可顯示,顯示的顏色有 256x256x256這麼多種顏色. 此範例配合Android手機藍芽控制RGB LED亮或暗.

DIY材料:
1. Motoduino / Arduino
2. Bluetooth
3. Arduino Color Shield
4. 8x8 RGB LED
5. Android 手機

                                                                 Motoduino

                                                                  Arduino Colors Shield


                                                                   8x8 RGB LED

                                                                 組合上去

                                                             8x8 RGB LED

影片請看: http://www.youtube.com/watch?v=UBoWGyyYmic

更多影片請看: http://www.youtube.com/user/sinocgtchen
部落格 : http://sinocgtchen.blogspot.com
Motoduino資訊: http://motoduino.com


2012年4月20日 星期五

Changes Bluetooth Baud Rate / Name on Motoduino/Arduino (AT Command)

這次來說明另一個簡單的方式修改bluetooth設定值,利用Arduino IDE直接下AT Command給bluetooth修改藍芽名稱或Baud Rate等, 此範例以藍芽名稱為例, 修改Baud Rate方法一樣,AT Command不一樣而已.

步驟如下:
1.把Motoduino/Arduino MCU 移除,如下圖:


2. 需要一條4 pin 或 6 pin排線把BT跟Motoduino做連接,注意Bluetooth的RX接Motoduino/Arduino的RX, Bluetooth的TX接Motoduino/Arduino的TX. Bluetooth的Vcc接 板子Vcc, GND接GND, 只需接四根pin腳.如下圖:




3. 把板子連接PC, 打開Arduino IDE 選擇正確的 Serial Port,如下圖:

 

4. 注意Arduino IDE的baud rate設定,如果Bluetooth目前default baud rate是 57600,則設定為57600,和No Line Ending. 如下圖:



5. 開始下AT Command給bluetooth, 下 AT 則會回應 OK, 在此以修改藍芽名稱為例, AT+NAMEMOTOBT , ( 如修改baud rate則 AT+BAUD7 表示設定baud rate成 57600)


                                   

 6. Bluetooth 回應的訊息, OKsetname表示藍芽名稱修改完成.
                                                   
7. 移除板子電源,把Atmega328P or MCU 插上板子還原. 這樣就大功告成!!


部落格 : http://sinocgtchen.blogspot.com
Motoduino資訊: http://motoduino.com


2012年4月18日 星期三

手機遙控智慧車 = Motoduino(Arduino + L293D) + two Servos (伺服馬達) + Bluetooth

把兩顆伺服馬達(兩個自由度,可以承受13kg大扭力)架設在小車子上,且把照相功能的攝影鏡頭架在伺服馬達上,利用Motoduino跟藍芽傳輸控制訊號,Android­手機可以控制鏡頭角度,目前照相功能未整合進去,不過測試是沒問題的,下一階段在整合進去...


DIY使用材料:
1. Motoduino (Arduino + L293D)
2. Bluetooth module
3. MG995 Servo  x 2
4. 9V battery
5. 兩輪小車一台
6. IO Expansion Shield (option, 可省略)
7. Android phone









                                        IO Expansion Shield
  
                                                          
                                         MG995 伺服馬達



    影片:  http://www.youtube.com/watch?v=Ass0XSu98wE


更多影片請看: http://www.youtube.com/user/sinocgtchen
部落格 : http://sinocgtchen.blogspot.com
Motoduino資訊: http://motoduino.com


2012年4月8日 星期日

Stepper Motor Control (步進馬達控制) = Motoduino (Arduino+293D) + Stepper Motor

Motoduino這塊板子也可以控制步進馬達(stepper motor), 方法很簡單, 手上這顆是二相激磁四線式步進馬達, 電壓 5V, 精度1.8度, 電流 0.3A, 四線接法: 紅線接M1+, 棕色接M1-, 藍色接 M2-, 黃色接 M2+. 影片中實驗是順時針走 200步(200x1.8度=360)剛好一圈,逆時針走200步回原點. 


 影片請參考這裡 : http://www.youtube.com/watch?v=AIZBQgjQ3rQ

使用材料:


1. Motoduino
2. Stepper Motor (KH42JM2B011) 5V, 0.3A, 1.8 Deg.







The Sketch(for Motoduino):


#include <Stepper.h>

const int stepsPerRevolution = 200;  // change this to fit the number of steps per revolution
                                     // for your motor
const int Motor_E1 = 5; // digital pin 5 of Arduino (PWM)  
const int Motor_E2 = 6;  // digital pin 6 of Arduino (PWM)
const int Motor_M1 = 7;     // digital pin 7 of Arduino
const int Motor_M2 = 8;    // digital pin 8 of Arduino
//Stepper myStepper(stepsPerRevolution, 8,9,10,11);          
Stepper myStepper(stepsPerRevolution, Motor_M1, Motor_M2);          

void setup() {
  // set the speed at 60 rpm:
  myStepper.setSpeed(60);
  // initialize the serial port:
  Serial.begin(9600);
  pinMode(Motor_M1, OUTPUT);
  pinMode(Motor_M2, OUTPUT);

  digitalWrite( Motor_E1, HIGH);  // speed control
  digitalWrite( Motor_E2, HIGH);  // speed control
}

void loop() {
  // step one revolution  in one direction:
   Serial.println("clockwise");
  myStepper.step(stepsPerRevolution);
  delay(500);

   // step one revolution in the other direction:
  Serial.println("counterclockwise");
  myStepper.step(-stepsPerRevolution);
  delay(500);
}



Blog: http://sinocgtchen.blogspot.com
Motoduino : http://motoduino.com
Youtube: http://www.youtube.com/user/sinocgtchen
My Email: sinocgtchen@gmail.com


2012年3月11日 星期日

Motoduino / Arduino WiFi Shield ( IEEE 802.11b 無線網路擴充板)

Motoduino WiFi Shield v1.0主要是配合Arduino (Diecimila/Duemilanove/Uno) 及 Motoduino 板子所設計,讓Arduino/Motoduino能有無線網路的功能且提供IEEE 802.11b連線能力。此塊模組完全相容於 Asynclab WiShield 1.0 和 Cupperhead WiFi Shield




Motoduino WiFi模組特性(Microchip):
 802.11b Wi-Fi certified
 1Mbps and 2Mbps throughput speeds
 Supports both infrastructure (BSS) and ad hoc (IBSS) wireless networks
 Ability to create secured and unsecured networks
 WEP (64-bit and 128-bit)
 WPA/WPA2 (TKIP and AES) PSK
 Low power usage
 Sleep mode: 250μA
 Transmit: 230mA
 Receive: 85mA


腳位說明:
 1.SPI 介面
     * Slave select (SS) : Arduino pin 10 
     * Clock (SCK) : Arduino pin 13
     * Master in, slave out (MISO) : Arduino pin 12
     * Master out, slave in (MOSI) : Arduino pin 11
 2. Interrupt (Uses only one of the following, depending on jumper setting)
     * INT0 : Arduino pin 2 
     * DIG8 : Arduino pin 8 
 3. LED : Arduino pin 9 
     * To regain use of this pin, remove the LED jumper cap
 4. 5V power
 5. GND










實做應用參考網站:  http://www.youtube.com/user/sinocgtchen
 部落格參考網站 :   http://sinocgtchen.blogspot.com
 Motoduino相關資訊: http://motoduino.com



2012年3月6日 星期二

Remote Control LED Matrix = Android + Motoduino (Arduino) + MAX7219 + Bluetooth

最近做一個LED 8x8 實驗,主要是利用手機藍芽來控制一個8x8 LED,這個實驗不是很難,主要在硬體接線部分要搞清楚pin腳的對應.

使用材料:
1. LED 8x8 matrix
2. Bluetooth
3. Motoduino or Arduino
4. MAX7219
5. 27k 電阻
6. 10uF 電容
7. 0.1 uF 電容
8. 一些線材


線路圖請參考這裡(reference schematic): Arduino playground

手機程式下載處(download android apk): http://www.motoduino.com/tw/downloadfiles



  影片請看: http://www.youtube.com/user/sinocgtchen
   部落格 :  http://sinocgtchen.blogspot.com

   有任何問題或有興趣朋友,歡迎來信討論,謝謝!!