โดยเบื้องต้นก็มีเซ็นเซอร์ที่น่าสนใจอยู่หลายตัวนะครับ ที่พี่คิดว่าตรงที่สุดก็อาจจะหนีไม่พ่นเรื่องของ เซ็นเซอร์วัดอุณหภูมิ และแก๊ส ถ้าเป็นแก๊สก็มีตัวอย่างให้ดูประมาณนี้ครับ
Module MQ-2 FC-22 Smoke Gas Sensor Smoke methane gas liquefied flammable gas sensor module
ตัวอย่างการต่อใช้งาน
Code EX
/* Sample Arduino for MQ2 Smoke Sensor Shield
05/03/2011
**********************************************/
const int analogInPin = A0; // Analog input pin that the potentiometer is attached to
//const int analogOutPin = 9; // Analog output pin that the LED is attached to
int sensorValue = 0; // value read from the pot
int outputValue = 0; // value output to the PWM (analog out)
float thickness;
int count,count1;
void setup()
{
// initialize serial communications at 9600 bps:
Serial.begin(9600);
//pinMode(7, OUTPUT);
}
void loop()
{
count1++;
// read the analog in value:
sensorValue = analogRead(analogInPin);
// map it to the range of the analog out:
outputValue = map(sensorValue, 0, 1023, 0, 100);
// change the analog out value:
//analogWrite(analogOutPin, outputValue);
if(count1==30)
{
count1=0;
// print the results to the serial monitor:
//Serial.print("sensor = " );
//Serial.print(sensorValue);
Serial.print("\t output = ");
Serial.println(outputValue);
/*
thickness = 20000-(5000*(1023/(float)sensorValue)-1); //This relationship is wrong,According to demand, own calculations relationship
Serial.print("thicknes = ");
Serial.println( thickness);
*/
}
count++;
delay(100);
/*
if(count>=(255-outputValue))
{
count=0;
}
if(count < (255-outputValue)/2)
{
digitalWrite(7, HIGH); // set the LED on
delay(20);
}
// delay(1023-sensorValue);
else
{
digitalWrite(7, LOW); // set the LED off
delay(20);
}
*/
// delay(1023-sensorValue);
}
โดยเบื้องต้นน้องสามาถซิมมูเลทชั่น วงจรดูได้ แต่พี่ไม่แน่ใจว่าตัวเซ็นเซอร์แก๊สนี้จะมีให้ทดสอบรึป่าวนะครับ
…จากนั้นเราจากจะเอาโมโุลตัวนี้ไปประยุกค์เข้ากับ robot อื่นๆ ได้ต่อไปครับ