顯示具有 Arduino 標籤的文章。 顯示所有文章
顯示具有 Arduino 標籤的文章。 顯示所有文章

2016年7月29日 星期五

使用Python透過Bluetooth與Arduino連結


        這篇文章示範如何使用Python透過Bluetooth跟Arduino連結.並使用Python建立出來的圖形介面來控制Arduino上LED 的ON/OFF.
 底下實驗概念接線圖

   Python 因為是跨平台的程式語言所以也執行在windows或是Linux,底下範例是直接使用一般電腦及windows 10去做示範.Python原始程式碼只要稍微修改一下也可以改成使用在安裝Linux的系統上,如樹梅派.


底下是之前USB2Serial範例的介紹連結:
http://arbu00.blogspot.tw/2016/07/pythonarduinoled.html




    底下所建立出來的圖形介面如下圖所示,
當按下按鈕<check>去跟Arduino確認是否已經連線成功.
按下按鈕<ButtonA>則會傳送字元'a' 到arduino當指令去啟動LED跑馬燈1
按下按鈕<ButtonB>則會傳送字元'b' 到arduino當指令去啟動LED跑馬燈2
按下按鈕<ButtonC>則會傳送字元'c' 到arduino當指令去啟動LED閃燈的動作.
按下按鈕<Exit>則會傳送'ESC' 鍵字元到arduino當指令去結束視窗跟所有動作.
當成是執行時必須先按下<Check>Button 再reset Arduino才能順執行以確保連線成功.
 


底下圖示當按下Button A 時會傳字元'a' 到Arduino,即可進行跑馬燈動作.
 




2016年3月17日 星期四

Build the light sword with 3DP+Arduino(用3D列印+Arduino製作光劍)


    I used 3DP and arduino Nano to build the light sword.

There are 4 kind of LED blink modes.Just press buttom to change LED blink modes.
When you wave the sword, it can beep.




2016年1月9日 星期六

Arduino 5 Axis Robotic_Arm V2.0 (Arduino 五軸機械手臂)


  This is a 5 Axis Arduino Robotic Arm with 2 controlled method.
1. one is auto mode by programming in arduino nano chip
2 another is manual mode by using Joysticks.



    This page show you how to connect the arduino circuit,
Regarding how to download 3DP components and how to assemble it .
please see below website.

http://arbu00.blogspot.tw/2015/12/roboticarm-v20-arduino_23.html.


and below can download the Arduino source code for Robotic Arm.<roboticArm1_1.ino >

https://github.com/Ashing00/Arduino_RoboticArm/blob/master/roboticArm1_1.ino


2015年12月26日 星期六

ESP8266 WIFI(3) -Connected with Arduino



這次要介紹的是ESP8266接在Arduino Nano v3 .因為Arduino Nano 只有一個Uart port 這個port我們要保留下來跟電腦連線及做DEBUG用,所以在我的接線上我會利用Arduino D2 pin當RX ,D3 pin 當TX,直接接到ESP8266 的TX跟RX ,也就是
Arduino D2 pin 接到ESP8266 TX pin
Arduino D3 pin 接到ESP8266 RX pin

請先參考前兩篇ESP8266的介紹:

ESP8266 Wifi (1)---Connected with PC.

http://arbu00.blogspot.tw/2015/12/esp8266-wifi-1-connected-with-pc.html

http://arbu00.blogspot.tw/2015/12/esp8266-wifi2-update-firmware-and.html

上述(1)(2)動作都ok後才有辦法繼續以下操作.


在Arduino 的程式上則是準備 <SoftwareSerial>這個開源的library去規劃D2/D3為RX/TX的功能(Arduino端)
EX: SoftwareSerial WifiSerial(2,3); /* RX:D2, TX:D3 */
據說SoftwareSerial  只能設定Baud rate到19200,所以這就是為什麼我們是先要將
ESP8266的Baud rate只設在9600.
如果你用的是Arduino Mega2560有多組RX/TX的,則可以直接接ESP8266跑115200 Baud rate.


另外我們還會用到另一個開源的Library <ITEADLIB_Arduino_WeeESP8266-master>
https://github.com/itead/ITEADLIB_Arduino_WeeESP8266/archive/master.zip
是一個把ESP8266的AT command 提供了實作的函式呼叫.

2015年12月25日 星期五

ESP8266 WIFI(2) -update firmware and modify baud rate.





這篇介紹如何更新升級ESP8266的韌體及如何更改Baud rate.


1.首先請參考,底下這篇如何接線跟電腦連線
上述該篇的動作ok了才有辦法進以下動作.

因為我們要做燒錄ESP韌體所以,須把GPIO0接地(GND).這是唯一接線的差別.
燒錄完成之後把GPIO0移開接地,再斷電重開才能重新正常連線,


我買了一條新的CP210x系列的也是可以用一樣的接法,它本身有提供3.3V輸出,但是也不不足供電的,還是得額外提供3.3V電源,多買一條USB-UART只是因為我原本另一條PL的在我正職的工作上有其他用途,在家用的只好多買一條..
我這裡一樣是用LM2596S DC-DC 降壓電源模塊 提供穩定3.3V給ESP8266供電.




2015年12月23日 星期三

2015年12月18日 星期五

ESP8266 Wifi (1)---Connected with PC.




這是我使用的ESP8266-12E,ESP8266有很多型號 價格都一樣約NT 60就可以入手.差別主要大概是在天線不同及GPIO pin的數目,

<ESP8266-12E>





除了ESP8266之外,需要準備一個USB轉UART的線或是類似的模組都可以,透過這條線可以更新ESP8266的韌體以及連接PC作一些設定及實驗.



<Picture2 USB-UART>




<Picture 3> DC-DC 降壓模組 ,ESP8266 需要一個穩定的3.3V並且工作時電流會達到200mA
所以最好獨立供電,根據許多人的經驗如更新韌體失敗都是因為供電問題.
LM2596S DC-DC 降壓電源模塊



<Picture 4> 在這邊我仍然是用慣用的兩顆18650串聯供電會達最高8.6V,接上降壓模組之後藉由上面的小螺絲調整到3.3v輸出獨立供電給ESP8266.




<Picture 5>底下是實際的接線,之後與Arduino的連接溝通留待以後在介紹,這裡只須先由USB-UART轉接線來連接PC及ESP8266.先作一些基本的連接及實驗



<Picture 6 >底下這個ESP8266官方的線路圖,參考就好


<Picture 7>實際的接線我是照這下面這張圖接,不過實驗過後發現兩個1K電阻都不上也行
例外REST的pin也可以不接,不過對於REST pin 我覺得是接上比較好,<這張圖是我從掏寶買
ESP8266時上面所附的.如有侵權請告知我.>



<線路實際接法>
  所以其實接線很簡單REST/CH_PD/VCC 都接到DC降壓模組轉輸出的3.3V
GPIO15/GND 可接到DC降壓模組轉輸出GND端

GPIO0 平時不接,如果把它接地代表著要進入更新韌體模式,更新完韌體須讓它離開接地
才能回到正常工作模式.有關韌體更新會另外篇幅介紹,與PC的連接不須更新韌體或更改設定即可做測試.

另外3 Pin 則是接到USB-uart 線的UART端.
ESP8266 的TX 要接到UART的RX
ESP8266 的RX 要接到UART的TX
ESP8266 的GND 要接到UART的GND 共地
至於UART端的VCC 或其他有CST 或RST pin的都不用接.
USB那端則直接接上PC.
這樣其實接線就完成了


<Picture 8> 當USB-UART (PL2303HX) 接上電腦時,要為它安裝上driver ,我是在windows 10做實驗,所以其實在win10上也是ok的 ,至於PL2303的driver 可以自行google搜尋都可以免費下載
或是按滑鼠右鍵讓win10自行去搜尋安裝(需有網路連線).

 裝好之後可以看到電腦會自動配一個Com port的號碼給它,在我電腦的例子是COM9
待會連線ESP8266就是要利用這個COM9 的port.


PS 所有相關的driver 或是測試用的軟體請自行google下載,我不貼連結因為那沒意義,就像
我常看別人的文章有貼軟體下載連結,但很多其實久了連結就失效了或是有更新的版本,有些還是奇怪的連結,最後還是得自行google搜尋. 所以這些driver還是軟體現在都google的到,幾乎都是免費的,我也是這樣下載的.







<用Realterm 做連接測試>
   線路接好了driver也裝好之後我們就可以來試試PC 與ESP8266能不能連線溝通.
底下先用Realterm做測試,有關COM port的測試軟體其實很多大多也都免費

   底下先介紹Realterm的測試方式
A.在<Display>可以選擇ANSI ,可以避免一些奇怪的字尾


B.在<Port>這一頁設定欲連接COM port的設定.
在[Baud]先設定為115200 或選擇9600
目前新買的ESP8266 預設Baud rate都是115200 除非去做韌體更改成9600 否則新買來的應該都是115200,如果不行的話再選9600或其他試試,如果選錯Baud 則可能出現亂碼也可能什麼都沒顯示, 
接著[port] 設成9 原因是剛剛PL2303H driver裝上時電腦配定為 COM9,這個數字必須根據你自己電腦上的driver安裝,幾乎我可以肯定你電腦的port號碼不會跟我一樣.要注意喔.
[stop Bit] 根據我的實驗必須選為1 bit就好,否則也是會有亂碼,但是也有人說選2 bits才不會亂碼.
如果有問題就都試試吧.
改變好設定後需要按一下[Change]它才會真的把剛剛的設定做變更
最後再按下[OPEN]鈕,打開COM9的連接.正常的話其實就已經可以連線ESP8266
接著就可以下一些AT command跟ESP8266做溝通. 
AT command 是ESP28266 的指令集,可以說ESP8266的功能就是透過這些AT command來做控制
有AT command可以自行在官網或是google搜尋,應該都找得到,這個版本也是一直在更新.
   底下只先介紹試驗3個基本AT command



C .切到<Send>頁面,把EOL的CR+LF打勾代表結尾符號
   第一個輸入AT 然後按下Send ASCII按鈕,s如果回傳OK ,表示與ESP8266已連接成功
第二個輸入AT+GMR(都要大寫) 則會回傳ESP8266的版本以及SDK的版本如下1.3.0


第三個輸入AT+RST(都要大寫) 則會reset重起ESP8266最後秀ready就是ok了
前端可能出現一小部分亂碼則沒關係,只要看到最後秀ready即是reset成功了.




<用SSCOM32做連接測試>
接下來介紹另一個測試軟體SSCOM32一樣可以google下載,我感覺這個設定會比Realterm 簡略一點,也它可以一次用檔案批次的方式輸入很多指令
A.重點依然是com port的選擇及Baud rate設定,在藍色的圈圈原本是秀OpenCom,按下連接之後
才變成CloseCom,表示連接com port或關閉.



底下一樣以AT /AT+GMR/AT+RST 做測試




基本上如果都成功了那與ESP8266的連接就是都ok了,
因為有關的ESP8266資料應用繁多之後再一一介紹.



有任何問題歡迎到我的FB粉絲團討論,只是我也不一定會就是了.
加入阿布拉機的3D列印與機器人的FB粉絲團
https://www.facebook.com/arbu00/

Scan QRcode to join FB Fans.
















2015年11月21日 星期六

Arduino BT_SmartCar_V2(藍芽智慧小車 V2.0)



     I re-designed my BT_Smart Car .The new architecture is more easy to assemble.

 download the  3DP components here:
http://www.thingiverse.com/thing:1147275

and just see the below pictures you will understand how to assemble it.


新的設計方便使用麵包版做實驗,並且設計成卡凖式的.電池盒,麵包版跟馬達裝進去
時都會有卡一聲.


加入阿布拉機的3D列印與機器人的FB粉絲團
https://www.facebook.com/arbu00/

Scan QRcode to join FB Fans.
1.Mechanism:

 1 All of 3DP components.

2015年11月5日 星期四

Build the BT_SmartCar with 3DP & Arduino -HW/SW section(用3D列印和arduino製作藍芽智慧小車-軟硬體部分)




     底下是主要的線路設計,最後還是用<MS小畫家>直接畫,為了方便性等等其他原因
全部都用模組化零件,這樣就算不是很懂電子電路的新手或小朋友也可以用麵包版,在不需任何焊接的情形下做好系統.


## <Below is my Bt_SmartCar H/W design & circuit ,It is conveinent to put all of modules on the Lab platform. without welding anything,I think it is good for children or education purpose.>

<Picture 1> 線路設計 <H/W Circuit> 可以另存新檔下載放大.



   
          有一個設計的重點要特別注意,我是用4顆 L9110H分別4顆驅動直流馬達(一個L9110H模組上有兩棵),一般其他設計上   L9110H 的輸入端IA/IB 有一真值表如<picture 2>,直接控制輸入high(高電位) or low(低電位).來控制正反轉,但是這樣不能控制速度,於是我把它改成用PWM的方式輸入IA/IB.PWM訊號等於0時就相當於low. 其他值100-255之間就相當於High(H)同時也可以控制速度.低於100的值有可能太低馬達扭力不足於驅動車子.

2015年10月31日 星期六

Build the BT_SmartCar with 3DP & Arduino -Mechanism section(用3D列印和arduino製作藍芽智慧小車-機構部分)





  這是我自己用3D印表機+Arduino設計的藍芽智慧小車,目前已完成了下面功能
1. 手機遙控模式:用android手機遙控藍芽智慧小車
2. 自走模式-------: 自走自動避障模式 ,防止掉落,靠近懸涯邊癌粽動後退改向
3. 循跡模式------:自動走線  (不反光黑線)  

可以從底下網址下載我設計的3D圖檔
http://www.thingiverse.com/thing:1104057


## I build a Bluetooth Smart Car with 3DP & Arduino.There below functions .
1.Mobile phone control mode -using Android control the BT_SmartCar
2.Auto mode-It cam auto avoid stuff and randomly change the move direction.
3.Line search mode ,Just Walking along the black line.

You can download my BT_SmartCar 3DP elements from below website.
http://www.thingiverse.com/thing:1104057



底下先介紹3D列印機構的組裝,
##Below are the assembly steps.

<Picture 1> 全部機構件,黃色部分的是一般常見的可買到的減速馬達組,我用了四顆所以她其實是四驅車.
<Picture 1> All elements ,for the yellow parts are the generic motor modules.I used 4 motors.


2015年10月20日 星期二

A Joystick example for Connecting arduino to mblock (scratch 2.0)(一個arduino連結到mblock的範例-搖桿使用)





       This  example show  how to connect the arduino to mblock(actually,it is scratch 2.0).
       I used one arduino UNO and one joystick.the H/W connection like below <picture 1>.
       please pay attation, I connect the joystick VCC to 3.3V not 5V.  
       than connected the USB to computuer usb port.


<Picture 1> Arduino UNO+ Joystick




2015年10月4日 星期日

Arduino Smart car with supersonic (Arduino 自動避障智慧小車)



   Using Arduino & spuersonic to implement the smart car.
 When it is driving and detected some stuff before  30cm distance,it can  brake automatically then
 drive backward a while and randomly change the  rightward or leftward direction.


運用Arduino 和超音波測距感測器實現智慧小車, 在偵測到物體約30cm之前
進行自動剎車,後退,隨機改變左右方向.






2015年9月13日 星期日

Using Android Phone to control House's Lamp ON/OFF(用Android手機遙控家裡電燈開關)





         My idea is just use one servo to switch the lamp's power button.
 Without Relay ,It just is a plug, It means we don't need to change house's original power circuits.




2015年9月10日 星期四

Using Android cell phone and Arduino + BT to control LED ON/OFF


    This is  a simple example to implement how to use android mobile phone to control LED ON/OFF thru Arduino +BT HC_05.


<Picture 1> This show the circuit design. I used the Arduino Digital Pin D2,D3 as  RX.TX signal.






<Picture2>  Using APP inventor 2 to create android APP .




2015年9月8日 星期二

How to build the Robotic Arm made by 3DP(用3D印表機來製作機械手臂)


     Although I already tried to made all screw hole on this Robotic Arm.but sometimes I got the new ideas and do some modification. so It is better to prepare the  Electrical screw tool,sometimes need to make some screw  holes.and please also prepare the glue for plastic material .



  Download the Robotic_Arm 3DP Components from the website:
  http://www.thingiverse.com/thing:994180

   Well, just reference below pictures to build the Robotic arm.


<picture 1>.It is better to fixed the Robotic Arm_base on the wood platform.or you can fixed it on where you want.


Using Arduino and Joystick to control Robotic Arm


            I created another method to control the Robotic Arm.

    Using Arduino nano & one Joystick with X/Y dimension and click function to control
  the robotic Arm's movements.

  This robotic arm architecture was made by my 3DP.
  You can  download the components from the website:
          http://www.thingiverse.com/thing:994180

Below films demo how to controll it .




2015年7月30日 星期四

Connecting Arduino for 5 axis Robotic Arm


This show you how to connect Arduino to Robotic Arm.I used 5 MG995 servo.MG995 servo can turn the angle from 0 -180 degree.Each Servo has 3 signal .VCC/GND/SIG.
VCC :+ power 5V or 6V
GND:Power ground
SIG: controled signal.


        來介紹一下之前做的機械手臂的接線方式,底下<圖一>是Tower pro Mg995的伺服馬達,轉動範圍可以0-180度 之間轉動,扭力號稱最大有13Kg,總共有三隻接腳 ,<正極> <負極> 及一<訊號腳> ,正負極接上電源後,只需控制 訊號腳 即可決定 轉動的角度 0-180度.


You can Download the Robotic Arm Elements from below website.
Robotic Arm 3DP elements

See the Demo Film


<Picture 1> The MG995 servo


<圖2> 這是書上只接一顆馬達的線路圖範例,將伺服馬達 <訊號腳> 接到 arduino 板子的D2 數位輸出腳,藉由程式控制這根訊號輸出來 控制馬達的轉動角度.
        接多顆馬達時一樣正負極接電源訊號腳則依序接D3,D4,D5,D6.,於是共5顆馬達分別由控制 D2 (伺服馬達1)/D3 (伺服馬達2) D4 (伺服馬達3)/D5 (伺服馬達4))/D6 (伺服馬達5)輸出訊號即可決定各伺服馬達的轉動角度.