1 / 9

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

智慧電子應用設計導論 (1/3) Sensors III. Chin-Shiuh Shieh ( 謝欽旭 ) http://bit.kuas.edu.tw/~csshieh Department of Electronic Engineering National Kaohsiung University of Applied Sciences, Taiwan. Humidity. Humidity (cont). void setup() { Serial.begin(9600); } void loop() {

Download Presentation

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

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

  2. Humidity C.-S. Shieh, EC, KUAS, Taiwan

  3. Humidity (cont) void setup() { Serial.begin(9600); } void loop() { Serial.println(analogRead(A0)); delay(500); } C.-S. Shieh, EC, KUAS, Taiwan

  4. Temperature/ Humidity • https://github.com/practicalarduino/SHT1x C.-S. Shieh, EC, KUAS, Taiwan

  5. Temperature/ Humidity (cont) #include <SHT1x.h> #define dataPin 2 #define clockPin 3 SHT1x sht1x(dataPin, clockPin); void setup() { Serial.begin(9600); Serial.println("Starting up"); } C.-S. Shieh, EC, KUAS, Taiwan

  6. Temperature/ Humidity (cont) void loop() { float temp_c; float temp_f; float humidity; // Read values from the sensor temp_c = sht1x.readTemperatureC(); temp_f = sht1x.readTemperatureF(); humidity = sht1x.readHumidity(); // Print the values to the serial port Serial.print("Temperature: "); Serial.print(temp_c, DEC); Serial.print("C / "); Serial.print(temp_f, DEC); Serial.print("F. Humidity: "); Serial.print(humidity); Serial.println("%"); delay(2000); } C.-S. Shieh, EC, KUAS, Taiwan

  7. 3-Axis Accelerometer • http://code.google.com/p/mma-7455-arduino-library/ C.-S. Shieh, EC, KUAS, Taiwan

  8. 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); } C.-S. Shieh, EC, KUAS, Taiwan

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

More Related