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
- Description: A microcontroller board based on the ATmega328P.
- Pins Used: 5V, GND, D4, D5.
YL-83 Rain Sensor - Detection Board
- Description: A board that detects rainwater through exposed traces.
- Pins Used: POS, NEG.
YL-83 Rain Sensor - Control Board
- Description: A board that processes the signal from the detection board and provides digital and analog outputs.
- Pins Used: VCC, GND, DO, AO, POS, NEG.
Tower Pro SG90 Servo
- Description: A small and lightweight servo motor suitable for RC and robotics applications.
- Pins Used: Signal, +5V, GND.
Wiring Details
Arduino UNO
- 5V: Connected to the VCC of the YL-83 Rain Sensor - Control Board and +5V of the Tower Pro SG90 servo.
- GND: Common ground with the YL-83 Rain Sensor - Control Board and Tower Pro SG90 servo.
- D4: Connected to the AO (Analog Output) of the YL-83 Rain Sensor - Control Board.
- D5: Connected to the Signal pin of the Tower Pro SG90 servo.
YL-83 Rain Sensor - Detection Board
- POS: Connected to the NEG pin of the YL-83 Rain Sensor - Control Board.
- NEG: Connected to the POS pin of the YL-83 Rain Sensor - Control Board.
YL-83 Rain Sensor - Control Board
- VCC: Powered by the 5V pin of the Arduino UNO.
- GND: Common ground with the Arduino UNO and Tower Pro SG90 servo.
- DO: Not connected in this circuit.
- AO: Connected to the D4 pin of the Arduino UNO.
- POS: Connected to the NEG pin of the YL-83 Rain Sensor - Detection Board.
- NEG: Connected to the POS pin of the YL-83 Rain Sensor - Detection Board.
Tower Pro SG90 Servo
- Signal: Controlled by the D5 pin of the Arduino UNO.
- +5V: Powered by the 5V pin of the Arduino UNO.
- GND: Common ground with the Arduino UNO and YL-83 Rain Sensor - Control Board.
Documented Code
#include <Servo.h>
Servo tap_servo;
int sensor_pin = 4;
int tap_servo_pin = 5;
int val;
void setup() {
pinMode(sensor_pin, INPUT);
tap_servo.attach(tap_servo_pin);
}
void loop() {
val = digitalRead(sensor_pin);
if (val == 0) {
tap_servo.write(0);
}
if (val == 1) {
tap_servo.write(180);
}
}
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.