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: **Wave Pattern**
- - Source Code NOT compiled for: Arduino Uno
- - Source Code created on: 2025-04-27 19:33:10
- ********* Pleasedontcode.com **********/
- /****** SYSTEM REQUIREMENTS *****/
- /****** SYSTEM REQUIREMENT 1 *****/
- /* Make the lights turn on and off in a wave pattern */
- /* 2 times when motion is detected with an ir */
- /* sensor */
- /****** END SYSTEM REQUIREMENTS *****/
- /* START CODE */
- /****** DEFINITION OF LIBRARIES *****/
- #include <IRremote.h> // Include the IRremote library
- /****** FUNCTION PROTOTYPES *****/
- void setup(void);
- void loop(void);
- // USER CODE
- const int ir = 5;
- const int LED1 = 13;
- const int LED2 = 12;
- const int LED3 = 11;
- int previousState = LOW;
- void setup(void)
- {
- // put your setup code here, to run once:
- pinMode(ir, INPUT);
- pinMode(LED1, OUTPUT);
- pinMode(LED2, OUTPUT);
- pinMode(LED3, OUTPUT);
- Serial.begin(9600); // Initialize serial communication at 9600 bits per second
- }
- void loop(void)
- {
- // put your main code here, to run repeatedly:
- int currentState = digitalRead(ir);
- if (previousState == LOW && currentState == HIGH) {
- // Wave pattern for LEDs
- for (int i = 0; i < 2; i++) { // Repeat the wave pattern 2 times
- digitalWrite(LED1, HIGH);
- delay(100);
- digitalWrite(LED2, HIGH);
- delay(100);
- digitalWrite(LED3, HIGH);
- delay(100);
- digitalWrite(LED3, LOW);
- delay(100);
- digitalWrite(LED2, LOW);
- delay(100);
- digitalWrite(LED1, LOW);
- delay(100);
- }
- } else {
- digitalWrite(LED3, LOW);
- digitalWrite(LED2, LOW);
- digitalWrite(LED1, LOW);
- }
- previousState = currentState; // Update previousState for the next loop iteration
- }
- /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement