From: acevest Date: Wed, 3 Dec 2014 10:29:28 +0000 (+0800) Subject: ... X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/zlib_tech.html?a=commitdiff_plain;h=fe9603227ade673f82eb7f758af72348f44dec78;p=acecode.git ... --- diff --git a/arduino/Sensors/Sensors.ino b/arduino/Sensors/Sensors.ino index 24d66bd..1a4db40 100644 --- a/arduino/Sensors/Sensors.ino +++ b/arduino/Sensors/Sensors.ino @@ -1,22 +1,12 @@ -#include - -const int ledPin = 12; int cnt = 0; - -Servo servo; - -int OldHumanBody = 0; - +const int ledPin = 12; void setup() { Serial.begin(9600); pinMode(ledPin, OUTPUT); - pinMode(0, INPUT); pinMode(1, INPUT); pinMode(2, INPUT); - - servo.attach(9); } void loop() { @@ -28,13 +18,16 @@ void loop() { int hb = analogRead(2); // Human Body + digitalWrite(ledPin, hb > 0 ? HIGH : LOW); + delay(100); - float temperature; - float resistance = (float)(1023-tv)*10000/tv; - temperature = 1/(log(resistance/10000)/3975+1/298.15) - 273.15; if(cnt % 10 == 0) { + float temperature; + float resistance = (float)(1023-tv)*10000/tv; + temperature = 1.00000/(log(resistance/10000)/3975+1/298.15) - 273.15; + Serial.print("Light Sensor Value: "); Serial.println(lv); @@ -52,34 +45,5 @@ void loop() { Serial.print(hb); Serial.println(" "); } - - if(lv < 400) - { - digitalWrite(ledPin, HIGH); - } - else - { - digitalWrite(ledPin, LOW); - } - - int degree = map(hb, 0, 1023, 0, 179); - - /* - Serial.print("fffffffffffffffffffffffffffffffffff: "); - Serial.print(OldHumanBody); - Serial.print(" "); - Serial.print(hb); - Serial.println(" ");*/ - - if(OldHumanBody ==0 && hb == 0) - { - - } - else - { - servo.write(degree); - } - - OldHumanBody = hb; }