Catalogue » Appliances » Parts & Accessories » Product details
Price comparison product image 3 Pack KY-020 Standard Tilt Switch Sensor Module for Arduino Diy Starter Kit

3 Pack KY-020 Standard Tilt Switch Sensor Module for Arduino Diy Starter Kit

by HUABAN
New from:
US $5.62
Shipping:
see website
Prices may incl. VAT *
Last refresh Jan/03/2019 01:01 AM
Brand
HUABAN
VCCA connects to 3.3V power supply
VCCB connects to 5V power supply
GND connects to power negative pole respectively, the two power supply should be common-grounded with each other
When Ax has TTL 3.3V input, Bx will get TTL 5V output
When Bx has TTL 5V input, Ax will get TTL 3.3V output
NO direction control required

Here we use the obstacle avoidance module and digital 13 interface with LED to build a simple circuit, making the obstacle avoidance warning light, accessing the avoidance sensor to digital 3 interface, when the obstacle avoidance sensor senses the signal, LED light, otherwise off.

Program code:
int Led=13;//define LED interface
int buttonpin=3; //define obstacle avoidance interface
int val;//define Digital variable val
void setup()
{
pinMode(Led, OUTPUT);//define LED is output interface
pinMode(buttonpin, INPUT);//define obstacle avoidance is output interface
}
void loop()
{
val=digitalRead(buttonpin);//reading the value from 3 digital interface to val
if(val==HIGH)//when the obstacle avoidance sensor senses the signal, LED flash
{
digitalWrite(Led, HIGH);
}
else
{
digitalWrite(Led, LOW);
}
}

Latest products for Price Comparison

* The prices and shipping costs may have changed since the last update. It is technically not possible to update the prices in real time. The time of purchase on the Website of the seller is used as the reference.