Mercury Tilt Switch Module with Light

$5.95

40 in stock

Description

Light Cup Code


/* SETUP

Light Cup       Arduino
-         -     GND
+         -     5V
S         -     D10
L         -     D13
*/
 
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);
  }
}

 

Additional information

Weight 0.002 kg

There are no reviews yet.

Be the first to review “Mercury Tilt Switch Module with Light”

Your email address will not be published. Required fields are marked *