else
{
digitalWrite(LedPinA, LOW);
}
if(digitalRead(ButtonPinB)==LOW) //Read sensor value
{
digitalWrite(LedPinB, HIGH);
}
else
{
digitalWrite(LedPinB, LOW);
}
}
//////////////////////////////////////////////////////////
Result
Tilt the circuit to one side, A light on, B light out; tilt to the other side, A light out, B light on.
*******************************************************************************
Project 20: Vibration switch
Introduction
Vibration switch, the correct name should be vibration sensor. It is a electronic switch sensing the
intensity of a vibration and transfer the result to the circuit device, and activate the circuit to start
working.
Hardware required
Arduino board *1
USB cable *1
Vibration Sensor*1
10KΩ resistor *3
Breadboard*1
Breadboard jumper wires* several
Schematic diagram
keyestudio
// Turn off LED when the sensor is not triggered
// Turn on LED when the sensor is tilted
// Turn off LED when the sensor is not triggered
www.keyestudio.cc
85
Need help?
Do you have a question about the ARDUINO maker learning kit and is the answer not in the manual?