Presentation is loading. Please wait.

Presentation is loading. Please wait.

Autumn, 2012C.-S. Shieh, EC, KUAS, Taiwan1 智慧電子應用設計導論 (1/3) Sensors I Chin-Shiuh Shieh ( 謝欽旭 ) Department of Electronic.

Similar presentations


Presentation on theme: "Autumn, 2012C.-S. Shieh, EC, KUAS, Taiwan1 智慧電子應用設計導論 (1/3) Sensors I Chin-Shiuh Shieh ( 謝欽旭 ) Department of Electronic."— Presentation transcript:

1 Autumn, 2012C.-S. Shieh, EC, KUAS, Taiwan1 智慧電子應用設計導論 (1/3) Sensors I Chin-Shiuh Shieh ( 謝欽旭 ) http://bit.kuas.edu.tw/~csshieh Department of Electronic Engineering National Kaohsiung University of Applied Sciences, Taiwan

2 Autumn, 2012C.-S. Shieh, EC, KUAS, Taiwan2 Light

3 Autumn, 2012C.-S. Shieh, EC, KUAS, Taiwan3 Light (cont) void setup() { Serial.begin(9600); } void loop() { int sensorReading = analogRead(A0); Serial.println(sensorReading); int thisPitch = map(sensorReading, 400, 1000, 120, 1500); tone(2, thisPitch, 10); delay(10); }

4 Autumn, 2012C.-S. Shieh, EC, KUAS, Taiwan4 Pressure

5 Autumn, 2012C.-S. Shieh, EC, KUAS, Taiwan5 Pressure (count) void setup() { Serial.begin(9600); } void loop() { int sensorReading = analogRead(A0); Serial.println(sensorReading); int thisPitch = map(sensorReading, 0, 800, 120, 1500); tone(2, thisPitch, 10); delay(1); }

6 Autumn, 2012C.-S. Shieh, EC, KUAS, Taiwan6 PIR

7 Autumn, 2012C.-S. Shieh, EC, KUAS, Taiwan7 PIR (cont) int ledPin = 13; int switchPin = 2; int value = 0; void setup() { pinMode(ledPin, OUTPUT); pinMode(switchPin, INPUT); } void loop() { value = digitalRead(switchPin); if (HIGH == value) { digitalWrite(ledPin, HIGH); } else { digitalWrite(ledPin, LOW); }

8 Autumn, 2012C.-S. Shieh, EC, KUAS, Taiwan8 PING )))

9 Autumn, 2012C.-S. Shieh, EC, KUAS, Taiwan9 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); }

10 Autumn, 2012C.-S. Shieh, EC, KUAS, Taiwan10 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; }

11 Autumn, 2012C.-S. Shieh, EC, KUAS, Taiwan11 Temperature http://www.arduino.cc/playground/Learning/One Wirehttp://www.arduino.cc/playground/Learning/One Wire

12 Autumn, 2012C.-S. Shieh, EC, KUAS, Taiwan12 Loudness

13 Autumn, 2012C.-S. Shieh, EC, KUAS, Taiwan13 Loudness (cont) void setup() { Serial.begin(9600); } void loop() { Serial.println(analogRead(A0)); delay(500); }


Download ppt "Autumn, 2012C.-S. Shieh, EC, KUAS, Taiwan1 智慧電子應用設計導論 (1/3) Sensors I Chin-Shiuh Shieh ( 謝欽旭 ) Department of Electronic."

Similar presentations


Ads by Google