feat: Initialized Repository
This commit is contained in:
42
Arduino/Blink/Blink.ino
Executable file
42
Arduino/Blink/Blink.ino
Executable file
@@ -0,0 +1,42 @@
|
||||
const int ledPin = 4; // Define the LED pin
|
||||
const int minOnTime = 100; // Minimum time LED is ON in milliseconds
|
||||
const int maxOnTime = 3000; // Maximum time LED is ON in milliseconds
|
||||
const int minOffTime = 50; // Minimum time LED is OFF in milliseconds
|
||||
const int maxOffTime = 200; // Maximum time LED is OFF in milliseconds
|
||||
|
||||
unsigned long previousMillis = 0;
|
||||
int ledState = LOW;
|
||||
unsigned long onTime = 0;
|
||||
unsigned long offTime = 0;
|
||||
|
||||
void setup() {
|
||||
pinMode(ledPin, OUTPUT);
|
||||
generateRandomTimes();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
unsigned long currentMillis = millis();
|
||||
|
||||
if (ledState == LOW) {
|
||||
if (currentMillis - previousMillis >= offTime) {
|
||||
// Turn the LED on
|
||||
ledState = HIGH;
|
||||
previousMillis = currentMillis;
|
||||
generateRandomTimes();
|
||||
}
|
||||
} else {
|
||||
if (currentMillis - previousMillis >= onTime) {
|
||||
// Turn the LED off
|
||||
ledState = LOW;
|
||||
previousMillis = currentMillis;
|
||||
generateRandomTimes();
|
||||
}
|
||||
}
|
||||
|
||||
digitalWrite(ledPin, ledState);
|
||||
}
|
||||
|
||||
void generateRandomTimes() {
|
||||
onTime = random(minOnTime, maxOnTime + 1); // Generate a random ON time
|
||||
offTime = random(minOffTime, maxOffTime + 1); // Generate a random OFF time
|
||||
}
|
1
Arduino/Blink/Blink.txt
Executable file
1
Arduino/Blink/Blink.txt
Executable file
@@ -0,0 +1 @@
|
||||
Turn an LED on and off.
|
Reference in New Issue
Block a user