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: "Serial Car Lights"
- - Source Code compiled for: Arduino Uno
- - Source Code created on: 2024-03-16 12:51:52
- ********* Pleasedontcode.com **********/
- /****** SYSTEM REQUIREMENTS *****/
- /****** SYSTEM REQUIREMENT 1 *****/
- /* when car moves front lights on */
- /****** END SYSTEM REQUIREMENTS *****/
- /****** DEFINITION OF LIBRARIES *****/
- #include <SoftwareSerial.h>
- /****** FUNCTION PROTOTYPES *****/
- void setup(void);
- void loop(void);
- /***** DEFINITION OF Software Serial *****/
- const uint8_t L293DMotorShield_HC05_mySerial_PIN_SERIAL_TX_A0 = A0;
- const uint8_t L293DMotorShield_HC05_mySerial_PIN_SERIAL_RX_A1 = A1;
- SoftwareSerial L293DMotorShield_HC05_mySerial(L293DMotorShield_HC05_mySerial_PIN_SERIAL_RX_A1, L293DMotorShield_HC05_mySerial_PIN_SERIAL_TX_A0);
- // Define pin for front lights
- const uint8_t frontLightsPin = 2;
- // Define variable to track car movement
- bool carMoving = false;
- void setup(void)
- {
- // put your setup code here, to run once:
- L293DMotorShield_HC05_mySerial.begin(9600);
- // Setup code for front lights
- pinMode(frontLightsPin, OUTPUT);
- digitalWrite(frontLightsPin, LOW); // Initially turn off front lights
- }
- void loop(void)
- {
- // put your main code here, to run repeatedly:
- // Code to check car movement and turn on/off front lights
- if (carMoving) {
- digitalWrite(frontLightsPin, HIGH); // Turn on front lights
- } else {
- digitalWrite(frontLightsPin, LOW); // Turn off front lights
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement