Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino UNO Controlled Rain-Activated Servo System

View and Edit Project In Cirkit DesignerImage of Arduino UNO Controlled Rain-Activated Servo System

Circuit Documentation

Summary

The circuit in question is designed to interface an Arduino UNO with a YL-83 Rain Sensor and a Tower Pro SG90 servo motor. The Arduino UNO reads the analog output from the rain sensor's control board and controls the servo motor based on the sensor's readings. When the rain sensor detects water, the servo motor is instructed to move to a specific position.

Component List

Arduino UNO

YL-83 Rain Sensor - Detection Board

YL-83 Rain Sensor - Control Board

Tower Pro SG90 Servo

Wiring Details

Arduino UNO

YL-83 Rain Sensor - Detection Board

YL-83 Rain Sensor - Control Board

Tower Pro SG90 Servo

Documented Code

#include <Servo.h>

Servo tap_servo;

int sensor_pin = 4; // Analog input from the rain sensor
int tap_servo_pin = 5; // Digital output to control the servo
int val; // Variable to store the sensor reading

void setup() {
  pinMode(sensor_pin, INPUT); // Initialize the sensor pin as an input
  tap_servo.attach(tap_servo_pin); // Attach the servo motor to its control pin
}

void loop() {
  val = digitalRead(sensor_pin); // Read the value from the rain sensor

  if (val == 0) {
    tap_servo.write(0); // If the sensor is dry, set servo to 0 degrees
  }
  if (val == 1) {
    tap_servo.write(180); // If the sensor is wet, set servo to 180 degrees
  }
}

Filename: sketch.ino

This code snippet is designed to run on the Arduino UNO. It initializes the servo motor and reads the state of the rain sensor's analog output. Depending on the sensor's output, the servo motor is moved to either 0 or 180 degrees, representing the dry or wet state, respectively.