Soil Sensor w/ LCD screen feedback

For this assignment my partner and I used a soil sensor to send analog data to arduino then sending messages to a Backpack/LCD screen if a threshold was reached. I used a low value for the threshold for the video but probably would want a higher value or possibly use a map statement with the LCD backlight since we are collecting analog data. The wiring is very basic with the backpack, pin-AO/yellow is my input coming from the sensor.

Ziyi Liu & Arturo Leyva

 

#include <SoftwareSerial.h>

int i = 0;
SoftwareSerial lcd = SoftwareSerial(0,2);

int sensorPin = 0;
int sensorReading;

void setup() {
lcd.begin(9600);

lcd.write(0xFE);
lcd.write(0xD0);
lcd.write((uint8_t)0);
lcd.write((uint8_t)0);
lcd.write((uint8_t)255);
delay(10);

}

void loop() {
sensorReading = analogRead(sensorPin);
if (sensorReading < 150) {

lcd.write(0xFE);
lcd.write(0x58);

lcd.write(0xFE);
lcd.write(0xD0);
lcd.write((uint8_t)255);
lcd.write((uint8_t)0);
lcd.write((uint8_t)0);
delay(10);

lcd.println(“Water Plants”);
lcd.print(sensorReading);
lcd.print(” “);
lcd.print(“Low Moisture”);

} else {
lcd.write(0xFE);
lcd.write(0x58);

lcd.write(0xFE);
lcd.write(0xD0);
lcd.write((uint8_t)0);
lcd.write((uint8_t)0255);
lcd.write((uint8_t)0);
delay(10);

lcd.println(“Moisture Level”);
lcd.print(sensorReading);
lcd.print(” “);
}

delay(1000);
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s