Vibration Digital I/O Code
/*
* Project name:
vibration sensor
* Copyright
(c) Researchdesignlab.com
* Description:
* Test configuration:
MCU: AT89S52
Dev.Board: 8051
Oscillator: 11.0592 MHz
Software: Keil uVision3
*/
#include<reg51.h>
sbit VIB=P1^0;
sbit BUZZER=P2^0; // soil sensor PIN connected P1.0
void DELAY()
{ //delay of 3ms
unsigned int X=800000;
while(X--);
}
void main()
{
BUZZER=0;
DELAY();
while(1)
{
if(VIB==1)
BUZZER=1;
DELAY();
}
else
{
BUZZER=0;
}
}
}