Welcome to Hackster!
Hackster is a community dedicated to learning hardware, from beginner to pro. Join us, it's free!
ENERGEN
Published

How to use Raindrop Sensor

Greenhouse project basic

BeginnerFull instructions provided294
How to use Raindrop Sensor

Things used in this project

Hardware components

Arduino Uno
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Solderless Breadboard Half Size
Solderless Breadboard Half Size
×1
LED (generic)
LED (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Arduino schematic

Code

Project Code

Arduino
// Sensor pins pin D6 LED output, pin A0 analog Input

#define ledPin 6
#define sensorPin A0


void setup() {

  Serial.begin(9600);
  pinMode(ledPin, OUTPUT);
  digitalWrite(ledPin, LOW);

}


void loop() {

  Serial.print("Analog output: ");
  Serial.println(readSensor());
  delay(500);

}


//  This function returns the analog data to calling function

int readSensor() {

  int sensorValue = analogRead(sensorPin);  // Read the analog value from sensor
  int outputValue = map(sensorValue, 0, 1023, 255, 0); // map the 10-bit data to 8-bit data
  analogWrite(ledPin, outputValue); // generate PWM signal
  return outputValue;             // Return analog rain value

}

Credits

ENERGEN
17 projects • 10 followers
Youtube creator
Contact

Comments

Please log in or sign up to comment.