2016年1月31日 星期日

[7688 Duo] Station mode補完:Win 7下連外網

Station mode補完:更改Device name就能在Win 7下連外網
Ted Lee@CAVEDU
Jan. 31, 2016
88x31.png[1]

本文補充說明CAVEDU教育团隊曾吉弘老師所寫LinkIt Smart 7688 Duo and MCS basics投影片的第28頁:如果http://mylinkit.local連不上怎麼辨?
這個問題和您使用的AP是否為兩階段驗証有関,筆者在機器人王國教室內的無線網路环境下,切換至Station mode後就能輕鬆地連入http://mylinkit.local。總之,兩階段驗証的AP不OK啦!Crying…

我們的開發环境為:
  • H/W:
    • CPU:i7-4510U@2GHz 2.60GHz
    • RAM:8GB,DDR3L 1600
    • Laptop:ASUS M700-PU451LD
  • S/W:
    • OS:MS Windows 7專業版w/ SP1,64 bits
    • 浏覽器:Chrome,48.0.2564.97 m
  • 開發版:LinkIt Smart 7688 Duo(以下簡稱7688D),F/W版本:0.9.2,AP mode的預設SSID為v7688_cfg
因為我們是在Win 7上開發,在使用7688D預設的Device name(mylinkit)下,我們試过依照MakerPro開發社群平台提到安裝BonjourPSSetup.exe的方法,卻裝不起該services。好在有CAVEDU教育团隊曾吉弘及徐丰智兩位大師鼎力協助才得以順利完成,在此謝过啰~。

設定步驟如下:
  1. 切換至AP mode 有兩种切換的方法:第一、長按WiFi按鈕5秒;第二、晶片reset:長按WiFi按鈕20秒。
  2. 和7688D連線 
  3. 更改Device name 以英文字母的大、小寫+數字重新命名,例如:TedLee7688d。這是最関鍵的步驟!重新替device命名後,7688D的OpenWrt OS會啟动內部的DHCP來動態指定一個新IP給7688D的Station mode。
  4. 將電腦連至外網 选擇非兩階段驗証的AP,或者以英文命名的手機熱奌(hot spot)
  5. 在浏覽器上以http://新Device name.local/重新連入7688D 
  6. 設定外網 Detected Wi-Fi network选擇非兩階段驗証的AP,或者手機熱奌;Password為前項的密碼(不是OpenWrt root帳號的密碼!)。
  7.  新Device name已取得新IP 

参考資料:
  1. 六種授權條款

2016年1月13日 星期三

[Arduino] 使用Autodesk 的123D Circuits來玩Arduino

使用Autodesk 的123D Circuits來玩Arduino
Ted Lee@CAVEDU
Jan. 10, 2016
88x31.png[1]

本文將介紹
常見的家電紅外線遙控器來操作MeArm用四顆伺服馬達來模機器擬四軸機器手臂的動作。我們採用各個撃破演算法將題目拆解成兩大塊:紅外線搖控處理(Lab6_3_1)與MeArm操作,再搭配三個實驗(Lab6_3_1-3)來細細品甞Arduino在自動控制上的威力!
本範例过関後,可獲得LED灯光Fade卡一張。

難易度:易

材料:
  1. LED(Light-Emitting Diode,發光二極体)一顆
  2. 220W電阻一顆(色环:紅紅黑金)
  3. 杜邦線若干條
  4. 麵包板一塊
  5. Arduino Uno R3一塊(本系列文章皆簡稱為Arduino開發版
  6. A-B型USB傳輸線一條

第一個實驗將以Arduino IDE內建的範例程式集(built-in examples)中的Blink(註一)做為踏入Arduino殿堂的第一支程式,同時也測試一下前面設定了老半天的环境是否可以正確地誏我們開發程式(註二)。
開啟Blink後的程式碼(註三)為:
/*
  Blink
  Turns on an LED on for one second, then off for one second, repeatedly.

  Most Arduinos have an on-board LED you can control. On the Uno and
  Leonardo, it is attached to digital pin 13. If you're unsure what
  pin the on-board LED is connected to on your Arduino model, check
  the documentation at http://www.arduino.cc

  This example code is in the public domain.

  modified 8 May 2014
  by Scott Fitzgerald
 */


// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin 13 as an output.
  pinMode(13, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);              // wait for a second
  digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);              // wait for a second
}
它对應的程式流程圖為:

執行結果

註一:從範例中學習(learning by examples)[1]是學習寫程式(programming)最快的方法之一,筆者強烈推荐!
註二:大抵上,軟、硬体的專案(project)開發流程為:
註三:Arduino程式的基本架構(structure)由兩個副程式(subroutines)所組成:
  1. setup():程式執行前的設定(setting),稱之為初始化(initialize),例如:設定串列傳輸速率為9,600bps(bit per second)
  2. loop():不斷重複執行(repeatedly execution)的副程式控制碼(control code),例如:控制馬達不停轉動。
void setup() {
     
}
void loop() {
 
}

Lab1_1_2
接線图接線影片
執行結果

参考資料:
  1. 六種授權條款

2016年1月11日 星期一

[Makers(創客)] 從想法(Ideas)到作品(Works)的最後一哩路:創客空間(Maker Spaces)急遽加速的綜效

從想法(Ideas)到作品(Works)的最後一哩路:
創客空間(Maker Spaces)急遽加速的綜效
Ted Lee
Jan. 11, 2016
88x31.png[1]

從前,要將心中的想法做成作品,需要先學會某些專業知识、利用某些科技工具,再使用某些造价不斐的機台來達成。
科技的急遽發展,使得过往只能由少數領域專家(domain experts)所掌控的各類專業知识(domain knowledge)一時之間如水銀瀉地般在虛擬空間(virtual spaces)之中快速的產出與累積。這股驚濤拍岸的浪潮,也正如狂風掃落葉般以迅雷不及掩耳的姿態呼嘯地席捲而來。
美國最知名的創客空間TechShop的創始人馬克.哈奇(Mark Hatch)在他所著的《全世界在瘋什麼自造者運動?》中分享了數個因為失業而参與TechShop各類短期的課程,以便將他們腦袋中浮現的想法快速地創做出成品的成功案例!這些令人興奮的故事,都說明了創客空間整合了最新穎的科技、融合各領域的專業知识與可快速量產的各式機台正以前所未有態勢縮短作品製造成型的時間。

参考資料:
  1. 六種授權條款

2016年1月9日 星期六

[Arduino] Ex1_2:床頭灯控制(Fade)

Ex1_2:床頭灯控制(Fade)
Ted Lee@CAVEDU
Jan. 9, 2016
88x31.png[1]

本實驗延伸Ex1_1的Lab1_1_2,將LED的正極由原先接到Arduino第13腳改接到第9腳,並將程式由呼叫digitalWrite()改為呼叫analogWrite()。因為analogWrite()使用變更工作週期(duty cycle)PWM技術來模擬連續性的類比信号,故能使LED亮度而有漸明/暗的效果,也就是常聽到呼吸灯的由來。

本範例过関後,可獲得LED灯光Fade卡一張。

難易度:易

材料
  1. LED(Light-Emitting Diode,發光二極体)一顆
  2. 220W電阻一顆(色环:紅紅棕金)
  3. 杜邦線2條
  4. 麵包板一塊
  5. Arduino Uno R3一塊(本系列文章皆簡稱為Arduino開發版
  6. A-B型USB傳輸線一條

程式Fade.ino
在Arduino IDE中由Fade File->Examples->1.Basics->Fade開啟Arduino內建的範例程式。
int brightness = 0;    // how bright the LED is
int fadeAmount = 5;    // how many points to fade the LED by
void setup()  {   
  // declare pin 9 to be an output:   
  pinMode(9, OUTPUT);
} 
void loop()  {   
  // set the brightness of pin 9:   
  analogWrite(9, brightness);  
  // change the brightness for next time through the loop:   
  brightness = brightness + fadeAmount;  
  // reverse the direction of the fading at the ends of the fade:   
  if (brightness == 0 || brightness == 255){   
    fadeAmount = -fadeAmount ;   
  }       
  delay(30); // wait for 30 milliseconds to see the dimming effect    
}
流程圖.vsdx
執行結果
接線圖.fzz
高手必練
修改控制LED明滅度fadeAmount的值(例如:5->10),再覌察LED灯的明滅是否有不同變化

2016年1月3日 星期日

[Arduino] 電路迴路(Circuit Loop)

電路迴路(Circuit Loop)
Ted Lee@CAVEDU
Jan. 3, 2016
88x31.png[1]

動畫中,任意挑選右邊的三條連接線(wire)將左邊的電池、開関(switch)與灯泡接起來,使得按下開関後灯泡就會奌亮。
這個動畫闡述了電路迴路(簡稱迴路)的動作原理:接妥線路後,
開関未按下時電路是不導通
相反的,按下開関後,電流從電池的正極(+)出發,流向開關、灯泡,再回到電池的負極(-),形成一條封閉的迴路(closed loop),即稱為此電路的迴路。
這整個过程可以將Loop.txt匯入(import)到Paul Falstad的Circuit Simulator Applet即見分明!

PS 也可以使用Autodesk出的網頁版(web-based)工具 123D Circuits來玩!
本概念过関後,可獲得迴路一張。

参考資料:
  1. 六種授權條款,台灣創用CC計畫,http://creativecommons.tw/explore。


2016年1月2日 星期六

[Arduino] Ex1_1:一閃一閃亮晶(Blink)

Ex1_1:一閃一閃亮晶(Blink)
Ted Lee@CAVEDU
Jan. 2, 2016
88x31.png[3]

本文從Arduino專案開發前的工作环境建置、測試,引入了毋需接電路(Lab1_1_1)及需另接電路(Lab1_1_2)兩個實驗來引領學員邁進Arduino的神秘殿堂,並援用了Arduino IDE內建範例集中的Blink來介紹Arduino控制程式的基本架構及語法。
本範例过関後,可獲得LED灯光Blink卡Arduino程式架構卡各一張。

難易度:易

材料:
  1. LED(Light-Emitting Diode,發光二極体)一顆
  2. 220W電阻一顆(色环:紅紅棕金)
  3. 杜邦線若干條
  4. 麵包板一塊
  5. Arduino Uno R3一塊(本系列文章皆簡稱為Arduino開發版
  6. A-B型USB傳輸線一條

Arduino開發环境建置
  1. Arduino的官網(official website)右側选擇與目前電腦中安裝的作業系統(Operating System)相符的版本[2]。
  2. 雙撃(double click)步驟1下載完成的「arduino-1.6.7-windows.exe」進行安裝。
  3. 在安裝的过程也會順帶將開發版的USB驅動程式(driver)一併裝妥。
  4. 选擇要安裝的目錄。
  5. 從File®Preferences中調整Arduino IDE(Integrated Development Environment)环境,設定顯示字型為14、標示程式碼的行号(line number)
  6. 將開發版以A-B型USB連接線串接電腦與開發版。
  7. 設定開發版的型号(board model)通信使用的埠号(port number)

    1. 從功能表Tools的Board: "Arduino/Genuino Uno"选擇我們使用的開發Arduino/Genuino Uno
    2. 設定板子和電腦的通信Port為COMx(編號x會因不同電腦及不同USB埠而配置(allocate)到不同的數值。一般而言,也就是說您和隔壁學員所「抽到」的號碼牌x不會同号,這是正常的情形喔,Don't panic!)。
  8. 將Blink.ino燒錄到開發版上。

這個範例有兩個實驗:

Lab1_1_1:奌亮內建(on-board)LED(使用Arduino第13腳內部連接的LED)
Lab1_1_2:奌亮外接LED(Arduino第13腳串接一限流電阻與LED)

從以下的Arduino開發版的電路图(schematic diagram)中,可以看到的第13腳(藍框)同時接到LED(綠框)及輸出。所以這兩個實驗都用同一接腳來奌亮LED,控制程式亦為同一支:Blink.ino。













Lab1_1_1
第一個實驗將以Arduino IDE內建的範例程式集(built-in examples)中的Blink(註一)做為踏入Arduino殿堂的第一支程式,同時也測試一下前面設定了老半天的环境是否可以正確地誏我們開發程式(註二)。
開啟Blink後的程式碼(註三)為:
/*
  Blink
  Turns on an LED on for one second, then off for one second, repeatedly.

  Most Arduinos have an on-board LED you can control. On the Uno and
  Leonardo, it is attached to digital pin 13. If you're unsure what
  pin the on-board LED is connected to on your Arduino model, check
  the documentation at http://www.arduino.cc

  This example code is in the public domain.

  modified 8 May 2014
  by Scott Fitzgerald
 */


// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin 13 as an output.
  pinMode(13, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);              // wait for a second
  digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);              // wait for a second
}

程式呼叫(invoke)了Arduino內建(built-in)API(Application Programming Interface,應用程式介面)中的三個函式:pinMode()digitalWrite()delay()來完成任務(註四)。

程式流程圖(flow chart)為:
/*
  Blink
  Turns on an LED on for one second, then off for one second, repeatedly.

  Most Arduinos have an on-board LED you can control. On the Uno and
  Leonardo, it is attached to digital pin 13. If you're unsure what
  pin the on-board LED is connected to on your Arduino model, check
  the documentation at http://www.arduino.cc

  This example code is in the public domain.

  modified 8 May 2014
  by Scott Fitzgerald
 */


// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin 13 as an output.
  pinMode(13, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);              // wait for a second
  digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);              // wait for a second
}


執行結果

註一:從範例中學習(learning by examples)[1]是學習寫程式(programming)最快的方法之一,筆者強烈推荐!
註二:大抵上,軟、硬体的專案(project)開發流程為:
Arduino程式的除錯技巧可参閱使用Autodesk 的123D Circuits來玩Arduino。
註三:Arduino程式(xxx.ino)的基本架構(structure)由兩個副程式(subroutines)所組成:
  1. setup():程式執行前的設定(setting),稱之為初始化(initialize),例如:設定串列傳輸速率為9,600bps(bit per second)
  2. loop():不斷重複執行(repeatedly execution)的副程式控制碼(control code),例如:控制馬達不停轉動。
void setup() {
     
}
void loop() {
 
}
註四:Arduino程式的語法(syntax)類C(C-like)高階程式語言(high-level programming language)。想流暢地駕馭程式創作,需要了解:
  1. 了解Arduino的基本語法 程式語言的語法好比英文的文法(grammar),一定要按照規定的格式(format)表述才能誏呆呆的電腦理解我們要交付的任務,例如:除了特殊指令(像if、while…)外,每條指令都一定要以;表程結尾。
  2. 學會查Arduino API文件 在學習Arduino專案程式開發的过程中,我們必需時時對這個官方提供的API有一定程度的了解:
    • API的架構(structure) 筆者將之分成以下六大類:
      1. I/O(Input/Output,輸入/輸出)
        1. 數位(Digital I/O)
        2. 類比(Analog I/O)
        3. 進階(Advanced I/O)
      2. 時間(Time)
      3. 數學(Math)
        1. 三角函數(Trigonometry)
        2. 乱數(Random Numbers)
      4. 字串(Strings)
        1. 字元(Characters)
        2. 位元(Bits)及位元組(Bytes)
      5. 中斷(Interrupts)
        1. 內部中斷(Internal Interrupts)
        2. 外部中斷(External Interrupts)
      6. 通信(Communication)
    • API函式的功能 例如:digitalWrite()是將高/低電位(HIGH/LOW)值輸出到Arduino開發版。
    • API函式的參數(parameter/argument) 以digitalWrite(pin,value)來說,它使用兩個参數來將value值輸出到Arduino開發版的pin腳位
Lab1_1_2
接線图.fzz)及接線影片
執行結果

参考資料:
  1. Learning Programming Fast In Just 5 Steps.
  2. Getting Started with Arduino on Windows.
  3. 六種授權條款