Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /********* Pleasedontcode.com **********
- Pleasedontcode thanks you for automatic code generation! Enjoy your code!
- - Terms and Conditions:
- You have a non-exclusive, revocable, worldwide, royalty-free license
- for personal and commercial use. Attribution is optional; modifications
- are allowed, but you're responsible for code maintenance. We're not
- liable for any loss or damage. For full terms,
- please visit pleasedontcode.com/termsandconditions.
- - Project: **Motor Control**
- - Source Code NOT compiled for: Arduino Uno
- - Source Code created on: 2025-02-16 13:00:23
- ********* Pleasedontcode.com **********/
- /****** SYSTEM REQUIREMENTS *****/
- /****** SYSTEM REQUIREMENT 1 *****/
- /* basically the components we used are rain sensor, */
- /* arduino uno r3 micro controller, motor driver */
- /* L293D, dc motors of 5v. motor driver vss pin and */
- /* vs pin ,motor driver enable pins have external */
- /* voltage supply . the circuit connections are as */
- /* follows */
- /****** END SYSTEM REQUIREMENTS *****/
- /* START CODE */
- /****** DEFINITION OF LIBRARIES *****/
- #include <L293D.h>
- #include <RainSensor.h>
- /****** FUNCTION PROTOTYPES *****/
- void setup(void);
- void loop(void);
- // Motor and sensor pin definitions
- const int motorA = 3; // Motor A pin
- const int motorB = 4; // Motor B pin
- const int enablePin = 5; // Enable pin for the motor driver
- const int rainSensorPin = 6; // Rain sensor pin
- // Create instances of the motor driver and rain sensor
- L293D motor(motorA, motorB, enablePin);
- RainSensor rainSensor(rainSensorPin);
- void setup(void)
- {
- // Initialize the motor driver
- motor.begin();
- // Initialize the rain sensor
- pinMode(rainSensorPin, INPUT);
- }
- void loop(void)
- {
- // Check the rain sensor
- if (rainSensor.isRaining()) {
- // If it is raining, stop the motors
- motor.Stop();
- } else {
- // If it is not raining, set the motor speed (example: 255 for full speed)
- motor.SetMotorSpeed(255);
- }
- }
- /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement