Arduino Tutorials – Lesson 47 – Vibration Sensor on Raspberry Pi Pico

To control Vibration Sensor using Raspberry Pi Pico

Required Components

  1. Vibration Sensor (SW 18010p)_1 no
  2. Raspberry Pi Pico_1 no
  3. Connecting wires_1 set

Circuit

Steps

  1. Make sure the components are working properly.
  2. Connect the Vibration Sensor to the Raspberry Pi Pico board.
  3. Connect the Raspberry Pi Pico board GP14th pin to the Vibration Sensor D0 Pin.
  4. Connect Vibration Sensor board VCC, GND to 3V3 (OUT), GND of Raspberry Pi Pico Board.
  5. Check the Electrical Circuit.
  6. Check the Arduino program.
  7. 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;
}

Leave a Reply

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