Skip to main content

 

   Sinhala Arduino Tutorial 10|Soil Sensor Module

                 
1st code-
 
int soil = A1;   //connect soil to A0
int value= 0; //define value 0
void setup()
{
 pinMode(soil,INPUT);
 Serial.begin(9600); //this is not necessary-but to show value to pc

}
void loop()
{
 value = analogRead(soil );  //read value-analog from A0
 Serial.println(value);    
 delay(100);
}

2nd code-

int soil =A1;
int value=0;
int led=13;

void setup()
{
 pinMode(soil,INPUT);
 pinMode(led,OUTPUT);
 Serial.begin(9600); //this is not necessary-but to show value to pc

}
void loop()
{
 value = analogRead(soil );  //read value-analog from A0
 Serial.println(value);    
 delay(100);
 
if(val>340){
digitalWrite(led,HIGH);

if(val>930){
digitalWrite(led,LOW);
}
delay(100);
}

Comments

Popular posts from this blog