Skip to content

Arduino-based system using sensors to control a motor, moving clothes based on environmental conditions. Bluetooth and switch control available

License

Notifications You must be signed in to change notification settings

KD-27/Automated-Clothesline

Repository files navigation

  1. The code includes the library NewPing.h, which is used for ultrasonic sensor functionality.

  2. The code defines the pin numbers for the ultrasonic sensor's trigger and echo pins (TRIGGER_PIN and ECHO_PIN) and the maximum distance to measure (MAX_DISTANCE).

  3. Two variables, ultra_threshold_1 and ultra_threshold_2, are defined to set the thresholds for the ultrasonic sensor distances.

  4. An instance of the NewPing class called sonar is created using the defined pin numbers and maximum distance.

  5. The code defines the pin number for the LDR (Light Dependent Resistor) sensor (LDRpin) and initializes a variable value to store the LDR sensor reading.

  6. A character variable blue is defined to store the received data from a Bluetooth connection.

  7. The code defines the pin number for the rain sensor (sensorPin).

  8. Two variables, int1 and int2, are defined to control the motor's direction.

  9. The code defines the pin number for a switch (switchPin) and sets it as an input with the internal pull-up resistor enabled.

  10. The setup() function is called once during the initialization phase.

  11. 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.

  12. Pin 3 is set as an output, and the motor speed is set to 100 using analogWrite().

  13. The loop() function is called repeatedly.

  14. Within the loop() function, it checks if there is any data available from the serial communication.

  15. If data is available, it reads the data into the blue variable and prints it to the serial monitor.

  16. The current state of the switch is read and stored in the switchState variable.

  17. The value of the LDR sensor is read and stored in the value variable.

  18. The ultrasonic sensor's distance is measured and stored in the distance variable.

  19. The distance and LDR sensor value are printed to the serial monitor.

  20. The rainSensor() function is called, and its return value is printed to the serial monitor.

  21. Depending on the value of blue and the state of the switch, different actions are performed.

  22. If blue is '0' and the switch state is HIGH, it checks the light intensity and the rain sensor value.

  23. If the light intensity is lower than 500 or the rain sensor value is greater than 10, it calls the ClothsMovingToTheShelter() function.

  24. If the light intensity is higher than 500 and the rain sensor value is less than 10, it calls the ClothsMovingAwayFromTheShelter() function.

  25. If blue is '1' or the switch state is LOW, it calls the ClothsMovingToTheShelter() function.

  26. The ClothsMovingToTheShelter() function checks if the distance is greater than ultra_threshold_1. If true, it moves the motor closer to the shelter.

  27. If the distance is less than ultra_threshold_2, the ClothsMovingAwayFromTheShelter() function moves the motor away from the shelter.

  28. The rainSensor() function reads the analog value from the rain sensor and maps it to a range of 255 to 0.

  29. The mapped outputvalue is returned by the rainSensor() function.

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

No packages published

Languages