-
The code includes the library
NewPing.h
, which is used for ultrasonic sensor functionality. -
The code defines the pin numbers for the ultrasonic sensor's trigger and echo pins (
TRIGGER_PIN
andECHO_PIN
) and the maximum distance to measure (MAX_DISTANCE
). -
Two variables,
ultra_threshold_1
andultra_threshold_2
, are defined to set the thresholds for the ultrasonic sensor distances. -
An instance of the
NewPing
class calledsonar
is created using the defined pin numbers and maximum distance. -
The code defines the pin number for the LDR (Light Dependent Resistor) sensor (
LDRpin
) and initializes a variablevalue
to store the LDR sensor reading. -
A character variable
blue
is defined to store the received data from a Bluetooth connection. -
The code defines the pin number for the rain sensor (
sensorPin
). -
Two variables,
int1
andint2
, are defined to control the motor's direction. -
The code defines the pin number for a switch (
switchPin
) and sets it as an input with the internal pull-up resistor enabled. -
The
setup()
function is called once during the initialization phase. -
In the
setup()
function, the serial communication is started at a baud rate of 9600. The necessary pin modes for the rain sensor, LDR sensor, motor control pins, and switch are set. -
Pin 3 is set as an output, and the motor speed is set to 100 using
analogWrite()
. -
The
loop()
function is called repeatedly. -
Within the
loop()
function, it checks if there is any data available from the serial communication. -
If data is available, it reads the data into the
blue
variable and prints it to the serial monitor. -
The current state of the switch is read and stored in the
switchState
variable. -
The value of the LDR sensor is read and stored in the
value
variable. -
The ultrasonic sensor's distance is measured and stored in the
distance
variable. -
The distance and LDR sensor value are printed to the serial monitor.
-
The
rainSensor()
function is called, and its return value is printed to the serial monitor. -
Depending on the value of
blue
and the state of the switch, different actions are performed. -
If
blue
is '0' and the switch state is HIGH, it checks the light intensity and the rain sensor value. -
If the light intensity is lower than 500 or the rain sensor value is greater than 10, it calls the
ClothsMovingToTheShelter()
function. -
If the light intensity is higher than 500 and the rain sensor value is less than 10, it calls the
ClothsMovingAwayFromTheShelter()
function. -
If
blue
is '1' or the switch state is LOW, it calls theClothsMovingToTheShelter()
function. -
The
ClothsMovingToTheShelter()
function checks if the distance is greater thanultra_threshold_1
. If true, it moves the motor closer to the shelter. -
If the distance is less than
ultra_threshold_2
, theClothsMovingAwayFromTheShelter()
function moves the motor away from the shelter. -
The
rainSensor()
function reads the analog value from the rain sensor and maps it to a range of 255 to 0. -
The mapped outputvalue is returned by the
rainSensor()
function.
-
Notifications
You must be signed in to change notification settings - Fork 0
Arduino-based system using sensors to control a motor, moving clothes based on environmental conditions. Bluetooth and switch control available
License
KD-27/Automated-Clothesline
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
Arduino-based system using sensors to control a motor, moving clothes based on environmental conditions. Bluetooth and switch control available
Topics
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published