I am able to detect a vibration when I am using 801s vibration sensor module sensor
How to measure and print the amount of vibration level on the screen in C? I am checking now only state: HIGH and LOW. I am using a digital signal not analog signal so my question is, can I use this type of signal in this sensor to display the value of vibration or we can't. How to retrieve the data from this sensor in C, value not only states high or low.
I am playing with the code from this video project
#include <wiringPi.h>
#include <stdio.h>
#define VibratePin 0
#define Gpin 1
#define Rpin 2
int tmp = 0;
void LED(int color)
{
pinMode(Gpin, OUTPUT);
pinMode(Rpin, OUTPUT);
if (color == 0)
{
digitalWrite(Rpin, HIGH);
digitalWrite(Gpin, LOW);
}
else if (color == 1)
{
digitalWrite(Rpin, LOW);
digitalWrite(Gpin, HIGH);
}
else
printf("LED Error");
}
void Print(int x){
if (x != tmp){
if (x == 0)
printf("Vibration Detected: .......Device1 On\n");
if (x == 1)
printf("Vibration Detected: Device2 On........\n");
tmp = x;
}
}
int main(void)
{
int status = 0;
int tmp = 0;
int value = 1;
if(wiringPiSetup() == -1){ //when initialize wiring failed,print messageto screen
printf("setup wiringPi failed !");
return 1;
}
pinMode(VibratePin, INPUT);
while(1){
value = digitalRead(VibratePin);
while(1){
value = digitalRead(VibratePin);
if (tmp != value){
status ++;
if (status > 1){
status = 0;
}
LED(status);
Print(status);
delay(1);
}
}
return 0;
}