Lab #4

Lab#4 

Date: March 3, 2017

Instructor: Antonius

By: Christina Oh

Aim/Goal:  Attach a moisture sensor to Arduino and use the data from your sensor to turn on and off an output.

Materials needed: Arduino kit, Moisture sensor, Wet sponge, Bread board, LED, Cables, 220 resistor.

In this lab, we could choose any input we would like to work on, and I choose to work with the moisture sensor. Moisture sensor used simple analog read, which was a little bit more easier for me to work on. First, I started by building the right circuit with Arduino and a moisture sensor, and test if the sensor is working well.

 

To test if the moisture sensor is correctly connected to arduino, I observed the numbers provided by the sensor in two cases. First, when I touch the sensor with my finger. Second, when I place the wet sponge on the sensor. As the numbers are shown on the screen, fingers are less moisturized than the wet sponge, thus numbers measured while I placed my fingers are around 60 but when I place the sponge, numbers suddenly jump up to around 550.

 

 

After I test whether the sensor is working correctly, I connected LED as an output to respond to the sensor. I made an LED to illuminate when the sensor detected enough moisture. I commend LED to illuminate when the sensor sense 300 or more of moisture. Thus, LED doesn’t light up when I place my finger, but it illuminates when I place the wet sponge.

int val;
void setup() {
  // put your setup code here, to run once:
Serial.begin(9600);
pinMode(13,OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
val=analogRead(0);
Serial.println(val);
if(val>120)
{digitalWrite(13, HIGH); 
}
else{digitalWrite(13, LOW); 
}
}

One thought on “Lab #4

Leave a Reply