int val = 0;
int soilPin = A0;
int motor = D3;
int speed = 0;
int led1 = D2;
void setup()
{
pinMode(soilPin, INPUT);
pinMode(motor, OUTPUT);
pinMode(led1, OUTPUT);
}
void loop()
{
val = analogRead(soilPin);
//
speed = map(val,0,4095,155,0);
//int speed2 = (int)
Particle.publish("Value", String(val));
Particle.publish("Speed", String(speed));//send current moisture value
//
if (val>1500) {
//
digitalWrite(motor, LOW);
//
digitalWrite(led1, LOW);
//
} else {
//
digitalWrite(motor, HIGH);
//
digitalWrite(led1, HIGH);
//
}
// }
analogWrite(motor,speed);
delay(1000);
}
Click to Expand
Content Rating
Is this a good/useful/informative piece of content to include in the project? Have your say!
You must login before you can post a comment. .