ขาย XD-78 Reed Switch Sensor Module ราคาที่ดีที่สุด
4.5
12
การให้คะแนน
61
ขายแล้ว
฿25
เรือจาก | จังหวัดฉะเชิงเทรา |
---|
รายละเอียดสินค้า
XD-78 Reed Switch Sensor Module Magnetron Module Reed Switch Magnetic Control Switch
- Imported normally-open reed
- Comparator output, clear signal, nice waveform and driving ability, more than 15mA.
- Working voltage: 3.3V-5V
- Output format: Digital switching output ( 0 and 1 )
- With fix bolt holes for easy installation
- Small PCB size: 32mm x 14mm
- Adopting LM393 comparator with wide voltage
Code:
/*
Arduino with Test XD-78 Reed Switch Sensor Module Magnetron
For complete project details, visit:Arduinoshop99
*/
int led = 12; // the pin that the LED is atteched to
int sensor = 2; // the pin that the sensor is atteched to
int state = LOW; // by default, no motion detected
int val = 0; // variable to store the sensor status (value)
void setup() {
pinMode(led, OUTPUT); // initalize LED as an output
pinMode(sensor, INPUT); // initialize sensor as an input
Serial.begin(115200); // initialize serial
}
void loop(){
val = digitalRead(sensor); // read sensor value
if (val == HIGH) { // check if the sensor is LOW
digitalWrite(led, LOW); // turn LED OFF
delay(100); // delay 100 milliseconds
if (state == HIGH) {
Serial.println(" CLEAR OK ");
Serial.println("");
state = LOW; // update variable state to C
}
}
else {
digitalWrite(led, HIGH); // turn LED ON
delay(200); // delay 200 milliseconds
if (state == LOW){
Serial.println("Warning Detect Magnetic");
Serial.println("");
state = HIGH; // update variable state to HIGH
}
}
}