To control Vibration Sensor using Raspberry Pi Pico
Required Components
- Vibration Sensor (SW 18010p)_1 no
- Raspberry Pi Pico_1 no
- Connecting wires_1 set
Circuit
Steps
- Make sure the components are working properly.
- Connect the Vibration Sensor to the Raspberry Pi Pico board.
- Connect the Raspberry Pi Pico board GP14th pin to the Vibration Sensor D0 Pin.
- Connect Vibration Sensor board VCC, GND to 3V3 (OUT), GND of Raspberry Pi Pico Board.
- Check the Electrical Circuit.
- Check the Arduino program.
- Run the Arduino program.
Arduino Program
int LED_Pin = 25;
int vibr_Pin = 14;
void setup()
{
pinMode(LED_Pin, OUTPUT);
pinMode(vibr_Pin, INPUT);
Serial.begin(9600);
}
void loop()
{
long measurement =TP_init();
delay(50);
Serial.println(measurement);
if (measurement > 1000)
{
digitalWrite(LED_Pin, HIGH);
}
else
{
digitalWrite(LED_Pin, LOW);
}
}
long TP_init()
{
delay(10);
long measurement=pulseIn (vibr_Pin, HIGH);
return measurement;
}