熱門文章

2017年8月28日 星期一

電導式濕度測量(組裝)

皮膚電阻感應


網路上很多用Arduino 加上sensor來測謊,原理是測量皮膚的電導度,(阻抗,電阻),這可用測皮膚的保濕度,引用並修改來連接Excel .不用processing 連接,用EXCEL 比較好儲存資料。




程式碼修改如下
/*

  Smoothing

  Reads repeatedly from an analog input, calculating a running average
  and printing it to the computer.  Keeps ten readings in an array and
  continually averages them.

  The circuit:
    * Analog sensor (potentiometer will do) attached to analog input 0

  Created 22 April 2007
  By David A. Mellis  
  modified 9 Apr 2012
  by Tom Igoe
  http://www.arduino.cc/en/Tutorial/Smoothing

  This example code is in the public domain.


*/


// Define the number of samples to keep track of.  The higher the number,
// the more the readings will be smoothed, but the slower the output will
// respond to the input.  Using a constant rather than a normal variable lets
// use this value to determine the size of the readings array.
const int numReadings = 10;

int readings[numReadings];      // the readings from the analog input
int readIndex = 0;              // the index of the current reading
int total = 0;                  // the running total
int average = 0;                // the average
int a = 0;
int inputPin = A0;
int Buzzerpin = 10;
void setup() {
  // initialize serial communication with computer:
  pinMode(Buzzerpin,OUTPUT);   
  digitalWrite(Buzzerpin,LOW); 
  Serial.begin(9600);
   Serial.println("LABEL,Number,Conductance");
  // initialize all the readings to 0:
  for (int thisReading = 0; thisReading < numReadings; thisReading++) {
    readings[thisReading] = 0;
  }
}

void loop() {
  // subtract the last reading:
  total = total - readings[readIndex];
  // read from the sensor:
  readings[readIndex] = analogRead(inputPin);
  // add the reading to the total:
  total = total + readings[readIndex];
  // advance to the next position in the array:
  readIndex = readIndex + 1;

  // if we're at the end of the array...
  if (readIndex >= numReadings) {
    // ...wrap around to the beginning:
    readIndex = 0;
  }
    // buzzle響 提示操作
    digitalWrite(Buzzerpin,HIGH);
     delay (10);
     digitalWrite(Buzzerpin,LOW);
     delay (1000);
     digitalWrite(Buzzerpin,HIGH);
     delay (10);
     digitalWrite(Buzzerpin,LOW);
   a = a + 1 ;
  // calculate the average:
  average = total / numReadings;
  // send it to the computer as ASCII digits
  //Serial.println(average);
  Serial.print("DATA");
  Serial.print(",");
  Serial.print("a");
  Serial.print(",");
  Serial.println(average);
  delay(2000);        // delay in between reads for stability
}


1 則留言:

  1. 對此儀器有興趣,
    請問這儀器是否可以外銷至歐洲國家

    回覆刪除