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