Presentation is loading. Please wait.

Presentation is loading. Please wait.

智慧電子應用設計導論(1/3) Sensor-III

Similar presentations


Presentation on theme: "智慧電子應用設計導論(1/3) Sensor-III"— Presentation transcript:

1 智慧電子應用設計導論(1/3) Sensor-III
Chin-Shiuh Shieh (謝欽旭) Department of Electronic Engineering National Kaohsiung University of Applied Sciences, Taiwan TA:范家禎、姜丞俞 Autumn, 2015 C.-S. Shieh, EC, KUAS, Taiwan

2 PING ))) – Ultra Sound Distance Measuring
測量範圍:2cm至3m 非常適合使用在機器人上,可以檢測移動中或靜止的物體,使用時只要微處理器的1個I/O即可以。 PING))) sensor使用發出超音波,從sensor到待測物,藉由接收回波所需要的時間來判對距離。

3 PING ))) (cont) const int pingPin = 2; void setup() {
Serial.begin(9600); } void loop() { long duration, inches, cm; pinMode(pingPin, OUTPUT);digitalWrite(pingPin, LOW); delayMicroseconds(2);digitalWrite(pingPin, HIGH); delayMicroseconds(5);digitalWrite(pingPin, LOW); pinMode(pingPin, INPUT);duration = pulseIn(pingPin, HIGH); cm = microsecondsToCentimeters(duration); Serial.print(cm);Serial.print("cm");Serial.println(); delay(100);

4 PING ))) (cont) long microsecondsToCentimeters(long microseconds) {
// The speed of sound is 340 m/s or 29 microseconds per centimeter. // The ping travels out and back, so to find the distance of the // object we take half of the distance travelled. return microseconds / 29 / 2; }

5 3-Axis Accelerometer MMA7455三軸加速度計模組 CS:高電位為I2C工作模式;低電位SPI工作模式。
INT1/INT2:使用者可以配置中斷點。 DATA:一個數位訊號輸出,可以測量X、Y、Z三軸的加速度或是傾斜角計算。 應用: 遙控控制傾斜感測、遙控飛機飛行穩定、多軸振動測量、動作感應資料收集。

6 3-Axis Accelerometer (cont)
#include <Wire.h> #include <MMA_7455.h> MMA_7455 mySensor = MMA_7455(); char xVal, yVal, zVal; void setup() { Serial.begin(9600); // Set the sensitivity you want to use // 2 = 2g, 4 = 4g, 8 = 8g mySensor.initSensitivity(2); // Calibrate the Offset, that values corespond in // flat position to: xVal = -30, yVal = -20, zVal = +20 // !!!Activate this after having the first values read out!!! //mySensor.calibrateOffset(0.23, -43.2, 12.43); }

7 3-Axis Accelerometer (cont)
void loop() { xVal = mySensor.readAxis('x'); yVal = mySensor.readAxis('y'); zVal = mySensor.readAxis('z'); Serial.print(xVal,DEC);Serial.print(" "); Serial.print(yVal,DEC);Serial.print(" "); Serial.print(zVal,DEC);Serial.print(" "); Serial.println(); delay(500); }

8 Gyroscope LISY300 單軸陀螺儀 提供最快300°/sec 的旋轉檢測,並且速度可以高達88Hz。 Dout:串列資料輸出。
SCLK:同步時脈輸入。 /CS:低電位致能。 應用: 直升機穩定、自動導航、平衡機器人。

9 Gyroscope (cont) #define LISY300_Dout 2 #define LISY300_SCLK 3
#define LISY300_CS 4 void setup() { Serial.begin(9600); pinMode(LISY300_Dout,INPUT); pinMode(LISY300_SCLK,OUTPUT);digitalWrite(LISY300_SCLK,HIGH); pinMode(LISY300_CS,OUTPUT);digitalWrite(LISY300_CS,HIGH); }

10 Gyroscope (cont) void loop() { int val=0;
digitalWrite(LISY300_CS,LOW); for(int i=0;i<13;i++) { digitalWrite(LISY300_SCLK,LOW); val=val*2+digitalRead(LISY300_Dout); digitalWrite(LISY300_SCLK,HIGH); } digitalWrite(LISY300_CS,HIGH); Serial.println(val); delay(100);

11 Color Sensor Module ColorPAL顏色感測器 ColorPAL使用其LED照亮樣本
一種色彩元素組成的時候,會隨著產生一種譜光,轉換到電壓轉換器來測量反射回來的光。 從樣本反射的光量,分成紅色(R),綠色(G)和藍色(B)三原色 來確定樣本的顏色。

12 GY-87 3-Axis Gyroscope, 3-axis Accelerometer, 3-Axis Digital Compass, Digital Pressure Sensor
10軸感測模組 整合 MPU-6050(三軸陀螺儀+三軸加速度) HMC5883L(三軸電子羅盤) BMP180(氣壓) DRDY:Data Ready, Interrupt Pin. Internally pulled high. Optional connection. Low for 250µsec when data is placed in the data output registers. INTA:Interrupt digital output (totem pole or open-drain) FSYNC:Frame synchronization digital input. Connect to GND if unused.


Download ppt "智慧電子應用設計導論(1/3) Sensor-III"

Similar presentations


Ads by Google