Arduino UNO 硬體介紹
google 搜尋關鍵字 Arduino UNO
google 搜尋關鍵字 arduino sensor shield
第一 個作業
將LED 改成 三個燈都可以輪流閃動
愛爾達MOOCx http://deltamoocx.net/ 看影片
老師的電子郵件 ardstu101@mst.hlis.hlc.edu.tw 問問題、交作業
Google ClassRoom https://classroom.google.com/c/NzQ1OTA2MDU4MVpa 點名、上課交流
創意文案參考網站:https://www.damanwoo.com/
智慧城市競賽網址 http://contest.mobilehero.com/
【Tutorial】LinkIt 7697三種開發環境,輕鬆上手! https://makerpro.cc/2017/06/introducing-linkit7697-development-environment/
範例 01.Basic --> Blink 測試電路、程式、連接是否正常。 程式技巧:內建常數、延遲方式
範例 02.Digital --> Button 變數設定、數位輸入。 程式技巧:if 指令
範例 03.Analog --> AnalogInOutSerial 串列傳輸設定、類比輸入
範例 01.Basic --> Fade 類比輸出 。 程式技巧:for 指令
範例 02.Digital --> ToneMelody 音調輸出。 程式技巧:陣列、#include "pitches.h"
組合練習
/*
* Ultrasonic Simple
* Prints the distance read by an ultrasonic sensor in
* centimeters. They are supported to four pins ultrasound
* sensors (liek HC-SC04) and three pins (like PING)))
* and Seeed Studio sesores).
*
* The circuit:
* * Module HR-SC04 (four pins) or PING))) (and other with
* three pins), attached to digital pins as follows:
* --------------------- ---------------------
* | HC-SC04 | Arduino | | 3 pins | Arduino |
* --------------------- ---------------------
* | Vcc | 5V | | Vcc | 5V |
* | Trig | 12 | OR | SIG | 13 |
* | Echo | 13 | | Gnd | GND |
* | Gnd | GND | ---------------------
* ---------------------
* Note: You need not obligatorily use the pins defined above
*
* By default, the distance returned by the distanceRead()
* method is in centimeters, to get the distance in inches,
* pass INC as a parameter.
* Example: ultrasonic.distanceRead(INC)
*
* created 3 Apr 2014
* by Erick Simões (github: @ErickSimoes | twitter: @AloErickSimoes)
* modified 23 Jan 2017
* by Erick Simões (github: @ErickSimoes | twitter: @AloErickSimoes)
* modified 03 Mar 2017
* by Erick Simões (github: @ErickSimoes | twitter: @AloErickSimoes)
*
* This example code is released into the MIT License.
*/
#include <Ultrasonic.h>
/*
* Pass as a parameter the trigger and echo pin, respectively,
* or only the signal pin (for sensors 3 pins), like:
* Ultrasonic ultrasonic(13);
*/
Ultrasonic ultrasonic(12, 13);
int val=0;
const int ledPin = 13; // the number of the LED pin
void setup() {
Serial.begin(9600);
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
}
void loop() {
val=ultrasonic.distanceRead();
if (val <= 10) {
// turn LED on:
digitalWrite(ledPin, HIGH);
} else {
// turn LED off:
digitalWrite(ledPin, LOW);
}
Serial.print("Distance in CM: ");
// Pass INC as a parameter to get the distance in inches
Serial.println(val);
delay(1000);
}