2016年4月17日 星期日

Arduino Smart Car V3.0(手機藍芽遙控多功能自走車V3.0)


  Base on Smart Car V2.0 to modify theUltraSonic portion.Add one servo(MG 90s) to check turn left or turn right when close the barrier.


See the previous Smart Car design:
http://arbu00.blogspot.tw/2015/11/arduino-btsmartcarv2-v20.html
 To connect Servo signal on D13 pin.

Download 3DP things from below website:
http://www.thingiverse.com/thing:1497224


Below source code just to reference ,it can work normally,but not yet perfect.
Download the new Arduino source code:
https://github.com/Ashing00/Smart_Car-V3.0/tree/master




2016年4月9日 星期六

Make the trible layer MAZE By 3DP(使用3D列印機製作三層陷阱迷宮)



  This maze have 3 layer ,Layer A and Layer B are the normal maze and Layer C is a trap layer
 Put a iron bell and try to find the way from  Entrance (A)  to Exit (B) .see the <Picture 6>

  Using your hand to control theiron bell and be careful that there are a lot of dead holes on the way.The squae hole are the dead holes.When the iron bell drop in.It will drop into trap layer C,then the game is over.
  You  need to get the iron bell from DEAD hole,then replay it again.The circle hole is right way to enter another maze layer B.On Layer B also have a lot of dead holes.Enjoy!

 Of cause you also can go from B to A.

Download this thing:
http://www.thingiverse.com/thing:1478081


To see below pictures to know how to made it.

<Picture 1> Just combine layer A.B.C .


2016年4月8日 星期五

2016年4月3日 星期日

C語言的指標及實作如何讀取應用程式執行時所附帶的參數


    今天要來介紹C語言的指標,以及如何利用指標來讀取執行應用程式時所附帶的參數.
原始程式碼下載:
https://github.com/Ashing00/pointer01/tree/master

        完整原始碼已放在在上述連結,只不過我是用visual studio 2013的win32控制台程式
去編譯,須注意你的編譯環境是否與我相同,如果使用不同的編譯環境有可能會發生
編譯不過發生錯誤情形,請再自行參考修正編譯錯誤問題,不過基本的原理是一樣的.

      一般來說學習C語言比較有可能遇到兩個較難理解的主題,一個是指標(pointer)另一個遞迴,有關遞迴會在另一篇文章介紹,然而了解遞迴之前最好先了解指標.

     指標(pointer) 簡單的來說就是指向我們電腦記憶體裡的位址(address),而一般我們所知道的
數值或是字元字串等等資料就是存放在這些記憶體位址裡的值(value).這樣的一個觀念在以前X86系統的組合語言裡反而是部會有太大的困擾的,因為學習組合語言必然要知道定址的方法
所以也必然會知道現在存放在暫存器如EBX,EDX的到底是位址(address)還是值(value).
    那C語言其實就是用指標(pointer) 來達到可以存取位址(address)的方法,只不過可能
是因為資料型態定義的方式在使用上容易跟原本的數值字串等等取值的資料型態搞混.
要搞懂它最好的辦法還是實機操作,底下的範例程式利用printf 的功能來一步步確認區分
究竟現在是位址(address)還是值(value).

    首先必須先知道C語言裡定義的兩個符號一個是*,另一個是&.
&指的是取出這個資料型態所存放值(value)的位址(address) 所在.
 所以他應該得到一個位址(address).

例如 pointer.c 宣告 一個int DataA  數值變數並給他初始值55.
當使用adr1 = &DataA; 這樣的敘述時我們可以指定存放數值55的這個記憶體位址給adr1
  於是adr1可以得到這個數值(value=55)存放的位址(address),請看圖一的說明.

*指的是從指標(pointer) 所存放的位址(address)去取出值(value),也就是它應該得到的是
 一個值(value),然而有趣的是在多重指標裡這個取出的值(value),本身也可能是代表指向另一地方的位址(address).請看圖一的說明再配合程式的執行.

<圖一> 底下應是偏移4位元組 <筆誤>