รู้จักสินค้านี้
KY-027 Magic Light Cup Module (โมดูลสวิทช์ปรอท)
Light Cup Module เป็นเซนเซอร์สวิตช์ปรอท รวมกับหลอดไฟ LED เราสามารถใช้เซนเซอร์ปรอทในการตรวจจับการเอียงเพื่อควบคุมเปิด/ปิด LED ได้
Mercury switches provide a digital signal that triggers the PWM , through the program design, we can then see the light like two cups filled with the effect of shuffling back and forth.
โค้ตตัวอย่าง KY-027
int Led = 13 ;// Declaration of the LED-output pin
int Sensor = 10; // Declaration of the sensor input pin
int val; // Temporary variable
void setup ()
{
pinMode (Led, OUTPUT) ; // Initialization output pin
pinMode (Sensor, INPUT) ; // Initialization sensor pin
digitalWrite(Sensor, HIGH); // Activating of the internal pull-up resistor
}
void loop ()
{
val = digitalRead (Sensor) ; // The current signal from the sensor will be read
if (val == HIGH) // If a signal will be detected, the LED will light up.
{
digitalWrite (Led, LOW);
}
else
{
digitalWrite (Led, HIGH);
}
}
http://sensorkit.en.joy-it.net/index.php?title=KY-027_Magic_light_cup_module