![chupacabra](/img/default-banner.jpg)
- Видео 33
- Просмотров 52 804
chupacabra
Добавлен 26 авг 2014
waddup
HOW TO USE ESP32CAM 2024
you can get the code by going to file examples esp32 camera camera web server
Просмотров: 48
Видео
Cum să faci seturi anti-rase(Plus demonstrare).
Просмотров 26 тыс.9 лет назад
Cum să faci seturi anti-rase(Plus demonstrare).
Nice system 👌👌👌
if u encounter problems setting RFID please comment i will help u
code #include <SPI.h> #include <MFRC522.h> #define RST_PIN 9 // Configurable, see typical pin layout above #define SS_PIN 10 // Configurable, see typical pin layout above #define GREEN_LED_PIN 7 // Pin where the green LED is connected (for authorized access) #define RED_LED_PIN 6 // Pin where the red LED is connected (for unauthorized access) MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance void setup() { Serial.begin(9600); // Initialize serial communications with the PC SPI.begin(); // Init SPI bus mfrc522.PCD_Init(); // Init MFRC522 pinMode(GREEN_LED_PIN, OUTPUT); // Set GREEN_LED_PIN as an output pinMode(RED_LED_PIN, OUTPUT); // Set RED_LED_PIN as an output digitalWrite(GREEN_LED_PIN, LOW); // Make sure the green LED is off initially digitalWrite(RED_LED_PIN, LOW); // Make sure the red LED is off initially } void loop() { // Reset the loop if no new card present on the sensor/reader. This saves the entire process when idle. if (!mfrc522.PICC_IsNewCardPresent()) { return; } // Select one of the cards if (!mfrc522.PICC_ReadCardSerial()) { return; } // Show UID on serial monitor Serial.print(F("RFID Card UID:")); for (byte i = 0; i < mfrc522.uid.size; i++) { Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "); Serial.print(mfrc522.uid.uidByte[i], HEX); } Serial.println(); // Check if the UID matches the one you want (authorized card) if (mfrc522.uid.uidByte[0] == 0xC3 && mfrc522.uid.uidByte[1] == 0x6B && mfrc522.uid.uidByte[2] == 0xFC && mfrc522.uid.uidByte[3] == 0x00) { Serial.println("Authorized RFID card detected!"); // Turn the green LED on digitalWrite(GREEN_LED_PIN, HIGH); // Keep the green LED on for 1 second delay(1000); // Turn the green LED off digitalWrite(GREEN_LED_PIN, LOW); } else { // If the card is not recognized, light up the red LED Serial.println("Unauthorized RFID card detected!"); // Turn the red LED on digitalWrite(RED_LED_PIN, HIGH); // Keep the red LED on for 1 second delay(1000); // Turn the red LED off digitalWrite(RED_LED_PIN, LOW); } // Halt PICC mfrc522.PICC_HaltA(); }
code: #include <WiFi.h> // Replace with your network credentials const char *ssid = "ESP32-AP"; const char *password = "123456789"; // Motor control pins const int motorIn1 = 27; const int motorIn2 = 26; const int motorEnable = 25; // PWM pin for speed control // Create an instance of the server WiFiServer server(80); void setup() { Serial.begin(115200); // Motor control pins setup pinMode(motorIn1, OUTPUT); pinMode(motorIn2, OUTPUT); pinMode(motorEnable, OUTPUT); // Set up the access point WiFi.softAP(ssid, password); Serial.println(); Serial.print("IP Address: "); Serial.println(WiFi.softAPIP()); server.begin(); } void loop() { WiFiClient client = server.available(); // Listen for incoming clients if (client) { // If a new client connects, String currentLine = ""; // make a String to hold incoming data from the client while (client.connected()) { // loop while the client's connected if (client.available()) { // if there's bytes to read from the client, char c = client.read(); // read a byte, then Serial.write(c); // print it out the serial monitor if (c == ' ') { // if the byte is a newline character // If the current line is blank, you got two newline characters in a row. // that's the end of the client HTTP request, so send a response: if (currentLine.length() == 0) { // HTTP headers client.println("HTTP/1.1 200 OK"); client.println("Content-type:text/html"); client.println(); // The HTML response client.print("<!DOCTYPE html><html>"); client.print("<head><title>ESP32 Motor Control</title></head>"); client.print("<body><h1>ESP32 Motor Control</h1>"); client.print("<p><button onclick=\"sendCommand('forward')\">Forward</button></p>"); client.print("<p><button onclick=\"sendCommand('backward')\">Backward</button></p>"); client.print("<p><button onclick=\"sendCommand('stop')\">Stop</button></p>"); // JavaScript to handle the button clicks without refreshing the page client.print("<script>"); client.print("function sendCommand(cmd) {"); client.print("fetch('/' + cmd).then(response => response.text()).then(data => console.log(data));"); client.print("}"); client.print("</script>"); client.print("</body></html>"); // End of HTTP response client.println(); break; } else { // If you got a newline, then clear currentLine currentLine = ""; } } else if (c != ' ') { // If you got anything else but a carriage return character, currentLine += c; // add it to the end of currentLine } // Check to see if the client request was to "/forward", "/backward" or "/stop" if (currentLine.endsWith("GET /forward")) { digitalWrite(motorIn1, HIGH); digitalWrite(motorIn2, LOW); analogWrite(motorEnable, 255); // Full speed } if (currentLine.endsWith("GET /backward")) { digitalWrite(motorIn1, LOW); digitalWrite(motorIn2, HIGH); analogWrite(motorEnable, 255); // Full speed } if (currentLine.endsWith("GET /stop")) { digitalWrite(motorIn1, LOW); digitalWrite(motorIn2, LOW); analogWrite(motorEnable, 0); // Stop motor } } } // Close the connection client.stop(); Serial.println("Client disconnected."); } }
code: #include <WiFi.h> // Access Point credentials const char* ap_ssid = "ESP32_AP"; const char* ap_password = "123456789"; // Create a server on port 80 WiFiServer server(80); // LED pin const int ledPin = 15; // GPIO pin where the LED is connected void setup() { Serial.begin(115200); delay(1000); // Initialize the LED pin as an output pinMode(ledPin, OUTPUT); digitalWrite(ledPin, LOW); // Ensure LED is off initially // Initialize the Wi-Fi as an Access Point WiFi.softAP(ap_ssid, ap_password); // Start the access point // Start the server server.begin(); Serial.print("Access Point IP address: "); Serial.println(WiFi.softAPIP()); } void loop() { WiFiClient client = server.available(); // Listen for incoming clients if (client) { Serial.println("New client connected"); // Process client request String request = client.readStringUntil(' '); Serial.println(request); client.flush(); // Control LED based on HTTP request if (request.indexOf("/led/on") != -1) { digitalWrite(ledPin, HIGH); // Turn the LED on } else if (request.indexOf("/led/off") != -1) { digitalWrite(ledPin, LOW); // Turn the LED off } // Send response to client client.println("HTTP/1.1 200 OK"); client.println("Content-Type: text/html"); client.println(); client.println("<!DOCTYPE HTML><html><head><style>"); client.println("body { font-family: Arial, sans-serif; }"); client.println("button { margin: 5px; padding: 10px; }"); client.println("#ledStatus { font-weight: bold; padding: 5px; border-radius: 5px; display: inline-block; transition: background-color 0.5s, color 0.5s; }"); client.println(".on { background-color: #4CAF50; color: white; }"); client.println(".off { background-color: #f44336; color: white; }"); client.println(".fade { animation: fadeIn 0.5s; }"); client.println("@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }"); client.println("</style></head><body>"); client.println("<h1>ESP32 Web Server</h1>"); client.println("<p>LED is <span id=\"ledStatus\" class=\"off fade\">Off</span></p>"); client.println("<button onclick=\"toggleLED('on')\">Turn LED On</button>"); client.println("<button onclick=\"toggleLED('off')\">Turn LED Off</button>"); client.println("<script>"); client.println("function toggleLED(state) {"); client.println(" var xhr = new XMLHttpRequest();"); client.println(" xhr.open('GET', '/led/' + state, true);"); client.println(" xhr.onreadystatechange = function () {"); client.println(" if (xhr.readyState == 4 && xhr.status == 200) {"); client.println(" var ledStatus = document.getElementById('ledStatus');"); client.println(" ledStatus.innerText = state.charAt(0).toUpperCase() + state.slice(1);"); client.println(" ledStatus.className = 'fade ' + (state === 'on' ? 'on' : 'off');"); client.println(" }"); client.println(" };"); client.println(" xhr.send();"); client.println("}"); client.println("</script>"); client.println("</body></html>"); client.stop(); // Close connection } }
Hello dosto
Hello nro
capacitors used : 4.7uF 50V and 220uF 16V code : const int speakerPin = 9; // PWM output pin void setup() { pinMode(speakerPin, OUTPUT); } void loop() { // Generate a simple tone tone(speakerPin, 440); // 440Hz tone (A4) delay(1000); // 1 second delay noTone(speakerPin); // Stop the tone delay(1000); // 1 second delay }
🍞📋
bro you showing how to use a switch... you just build a batterypack for your 5v usb stuff.
thatsliterally the point of the video
code : // Define motor control pins #define ENA 5 // Enable pin for motor A #define IN1 6 // Control pin 1 for motor A #define IN2 7 // Control pin 2 for motor A #define IN3 8 // Control pin 1 for motor B #define IN4 9 // Control pin 2 for motor B #define ENB 10 // Enable pin for motor B void setup() { // Initialize motor control pins as outputs pinMode(ENA, OUTPUT); pinMode(IN1, OUTPUT); pinMode(IN2, OUTPUT); pinMode(IN3, OUTPUT); pinMode(IN4, OUTPUT); pinMode(ENB, OUTPUT); // Start serial communication for debugging purposes Serial.begin(9600); } void loop() { // Start both motors at maximum speed digitalWrite(IN1, HIGH); digitalWrite(IN2, LOW); digitalWrite(IN3, HIGH); digitalWrite(IN4, LOW); analogWrite(ENA, 255); // Set motor A speed to maximum (255) analogWrite(ENB, 255); // Set motor B speed to maximum (255) Serial.println("Motors running at maximum speed"); // Wait for 10 seconds delay(5000); // Stop both motors digitalWrite(IN1, LOW); digitalWrite(IN2, LOW); digitalWrite(IN3, LOW); digitalWrite(IN4, LOW); analogWrite(ENA, 0); // Stop motor A analogWrite(ENB, 0); // Stop motor B Serial.println("Motors stopped"); // Wait for 2 seconds delay(2000); }
code : #include <Wire.h> #include <MPU6050.h> #include <Adafruit_SSD1306.h> #include <Adafruit_GFX.h> // OLED display width and height #define SCREEN_WIDTH 128 #define SCREEN_HEIGHT 64 // Initialize OLED display Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1); // Initialize MPU6050 MPU6050 mpu; float cubeSize = 40; // Increased cube size float angleX = 0; float angleY = 0; // Define the vertices of the cube float vertices[8][3] = { {-1, -1, -1}, {1, -1, -1}, {1, 1, -1}, {-1, 1, -1}, {-1, -1, 1}, {1, -1, 1}, {1, 1, 1}, {-1, 1, 1} }; // Define the edges connecting the vertices int edges[12][2] = { {0, 1}, {1, 2}, {2, 3}, {3, 0}, {4, 5}, {5, 6}, {6, 7}, {7, 4}, {0, 4}, {1, 5}, {2, 6}, {3, 7} }; void setup() { Wire.begin(); Serial.begin(115200); mpu.initialize(); if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { Serial.println(F("SSD1306 allocation failed")); for (;;); } display.display(); delay(1000); display.clearDisplay(); display.setTextSize(1); display.setTextColor(SSD1306_WHITE); } void loop() { int16_t ax, ay, az; int16_t gx, gy, gz; // Read accelerometer and gyroscope values mpu.getMotion6(&ax, &ay, &az, &gx, &gy, &gz); // Convert raw gyro values to angles in degrees angleX = gy / 131.0; angleY = gx / 131.0; // Clear display display.clearDisplay(); // Draw the rotated cube drawCube(angleX, angleY); // Display the updated frame display.display(); delay(50); // Adjust for smoothness } void drawCube(float angleX, float angleY) { float rotatedVertices[8][2]; for (int i = 0; i < 8; i++) { // Rotate around X-axis float x = vertices[i][0]; float y = vertices[i][1] * cos(radians(angleX)) - vertices[i][2] * sin(radians(angleX)); float z = vertices[i][1] * sin(radians(angleX)) + vertices[i][2] * cos(radians(angleX)); // Rotate around Y-axis float newX = x * cos(radians(angleY)) + z * sin(radians(angleY)); float newY = y; float newZ = -x * sin(radians(angleY)) + z * cos(radians(angleY)); // Project 3D coordinates to 2D rotatedVertices[i][0] = newX * (cubeSize / (newZ + 4)) + SCREEN_WIDTH / 2; rotatedVertices[i][1] = newY * (cubeSize / (newZ + 4)) + SCREEN_HEIGHT / 2; } // Draw edges for (int i = 0; i < 12; i++) { display.drawLine(rotatedVertices[edges[i][0]][0], rotatedVertices[edges[i][0]][1], rotatedVertices[edges[i][1]][0], rotatedVertices[edges[i][1]][1], SSD1306_WHITE); } }
Cool
code : #include <IRremote.h> #include <Wire.h> #include <Adafruit_GFX.h> #include <Adafruit_SSD1306.h> #include <Servo.h> #define SCREEN_WIDTH 128 #define SCREEN_HEIGHT 64 #define OLED_RESET -1 Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET); const int irReceiverPin = 2; IRrecv irrecv(irReceiverPin); decode_results results; Servo myservo; const int servoPin = 9; struct IRCommand { unsigned long code; const char *description; }; const IRCommand commands[] = { {0xBA45FF00, "Move to 0°"}, // Button 1 {0xB946FF00, "Move to 90°"}, // Button 2 {0xB847FF00, "Move to 180°"}, // Button 3 {0xBB44FF00, "Increment +20°"}, // Button 4 {0xBF40FF00, "Decrement -20°"}, // Button 5 }; int servoPosition = 90; void setup() { Serial.begin(9600); irrecv.enableIRIn(); if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { Serial.println(F("SSD1306 allocation failed")); for (;;); } display.clearDisplay(); display.setTextSize(1); display.setTextColor(SSD1306_WHITE); display.setCursor(0, 0); display.println("IR Remote Control"); display.display(); myservo.attach(servoPin); myservo.write(servoPosition); } void loop() { if (irrecv.decode()) { unsigned long irCode = irrecv.decodedIRData.decodedRawData; if (irCode == 0xFFFFFFFF) { irrecv.resume(); return; } Serial.println(irCode, HEX); bool commandFound = false; for (size_t i = 0; i < sizeof(commands) / sizeof(commands[0]); i++) { if (irCode == commands[i].code) { display.clearDisplay(); display.setCursor(0, 0); display.println("IR Remote Control"); display.setCursor(0, 20); display.print("Code: "); display.println(irCode, HEX); display.setCursor(0, 40); display.println(commands[i].description); switch (i) { case 0: // Button 1: Move to 0° servoPosition = 0; break; case 1: // Button 2: Move to 90° servoPosition = 90; break; case 2: // Button 3: Move to 180° servoPosition = 180; break; case 3: // Button 4: Increment +20° servoPosition = min(servoPosition + 20, 180); break; case 4: // Button 5: Decrement -20° servoPosition = max(servoPosition - 20, 0); break; } myservo.write(servoPosition); display.setCursor(0, 50); display.print("Position: "); display.print(servoPosition); display.println("°"); display.display(); commandFound = true; break; } } if (!commandFound) { display.clearDisplay(); display.setCursor(0, 0); display.println("IR Remote Control"); display.setCursor(0, 40); display.display(); } irrecv.resume(); } }
code: #include <LedControl.h> #define DIN_PIN 11 #define CS_PIN 10 #define CLK_PIN 13 #define JOY_X_PIN A0 #define JOY_Y_PIN A1 #define JOY_THRESHOLD 200 // Adjust this threshold as needed LedControl lc = LedControl(DIN_PIN, CLK_PIN, CS_PIN, 1); int dotX = 3; // Initial position of the dot int dotY = 3; void setup() { lc.shutdown(0, false); // Wake up displays lc.setIntensity(0, 8); // Set brightness level (0 is min, 15 is max) lc.clearDisplay(0); // Clear display register pinMode(JOY_X_PIN, INPUT); pinMode(JOY_Y_PIN, INPUT); // Initial dot position lc.setLed(0, dotY, dotX, true); } void loop() { int xVal = analogRead(JOY_X_PIN); int yVal = analogRead(JOY_Y_PIN); bool moved = false; // Calculate movement speed based on joystick position int speed = map(max(abs(xVal - 512), abs(yVal - 512)), 0, 512, 200, 50); // Check if joystick is moved right if (xVal > (512 + JOY_THRESHOLD)) { dotX = (dotX + 1) % 8; moved = true; } // Check if joystick is moved left if (xVal < (512 - JOY_THRESHOLD)) { dotX = (dotX - 1 + 8) % 8; moved = true; } // Check if joystick is moved down if (yVal > (512 + JOY_THRESHOLD)) { dotY = (dotY + 1) % 8; moved = true; } // Check if joystick is moved up if (yVal < (512 - JOY_THRESHOLD)) { dotY = (dotY - 1 + 8) % 8; moved = true; } // Update the LED matrix if the dot has moved if (moved) { lc.clearDisplay(0); // Clear the previous position lc.setLed(0, dotY, dotX, true); // Set the new position delay(speed); // Control speed based on joystick position } }
receiver : #include <SPI.h> #include <Wire.h> #include <Adafruit_GFX.h> #include <Adafruit_SSD1306.h> #include <RF24.h> #define SCREEN_WIDTH 128 #define SCREEN_HEIGHT 64 #define OLED_RESET -1 // Reset pin not used with SSD1306 Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET); RF24 radio(9, 10); // CE, CSN const byte address[6] = "00001"; void setup() { Serial.begin(9600); // Initialize OLED display with I2C address 0x3C if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { Serial.println(F("SSD1306 allocation failed")); for (;;) ; } // Clear the display buffer display.clearDisplay(); display.display(); // Initialize NRF24 module and start listening radio.begin(); radio.openReadingPipe(0, address); radio.setPALevel(RF24_PA_MIN); radio.startListening(); } void loop() { if (radio.available()) { float pulseValue; radio.read(&pulseValue, sizeof(pulseValue)); // Clear display buffer display.clearDisplay(); // Display pulse value on OLED display.setTextSize(2); display.setTextColor(SSD1306_WHITE); display.setCursor(0, 10); display.print("Pulse:"); display.setCursor(0, 40); display.print(pulseValue); // Assuming pulseValue is correctly received as float display.display(); } } transmitter : #include <SPI.h> #include <nRF24L01.h> #include <RF24.h> RF24 radio(9, 10); // CE, CSN const byte address[6] = "00001"; #define samp_siz 4 #define rise_threshold 5 int sensorPin = A0; // Analog pin connected to KY-039 sensor void setup() { Serial.begin(9600); radio.begin(); radio.openWritingPipe(address); radio.setPALevel(RF24_PA_MIN); radio.stopListening(); } void loop() { float reads[samp_siz], sum; long int now, ptr; float last, reader, start; float first, second, third, before, print_value; bool rising; int rise_count; int n; long int last_beat; for (int i = 0; i < samp_siz; i++) reads[i] = 0; sum = 0; ptr = 0; while (1) { n = 0; start = millis(); reader = 0.; // Average the sensor readings over a 20 ms period do { reader += analogRead(sensorPin); n++; now = millis(); } while (now < start + 20); reader /= n; // Calculate the average reading // Update the array with the latest measurement and maintain the sum sum -= reads[ptr]; sum += reader; reads[ptr] = reader; last = sum / samp_siz; // Check for a rising curve (= a heart beat) if (last > before) { rise_count++; if (!rising && rise_count > rise_threshold) { rising = true; first = millis() - last_beat; last_beat = millis(); // Calculate the weighted average of heartbeat rate print_value = 60000. / (0.4 * first + 0.3 * second + 0.3 * third); // Transmit the pulse value wirelessly radio.write(&print_value, sizeof(print_value)); // For debugging, you can print the value to serial monitor Serial.print("Pulse Value: "); Serial.println(print_value); third = second; second = first; } } else { rising = false; rise_count = 0; } before = last; ptr++; ptr %= samp_siz; delay(10); // Adjust delay as needed for stability } }
for any problems with the module comment and i will try to help you
transmitter code : #include <SPI.h> #include "RF24.h" #define CE_PIN 9 #define CSN_PIN 10 #define BUTTON_PIN 2 RF24 radio(CE_PIN, CSN_PIN); const byte address[6] = "00001"; void setup() { Serial.begin(115200); pinMode(BUTTON_PIN, INPUT_PULLUP); // Enable internal pull-up resistor radio.begin(); radio.openWritingPipe(address); radio.setPALevel(RF24_PA_LOW); radio.stopListening(); } void loop() { bool buttonState = digitalRead(BUTTON_PIN) == LOW; // Button pressed is LOW bool success = radio.write(&buttonState, sizeof(buttonState)); if (success) { Serial.println("Transmission successful!"); } else { Serial.println("Transmission failed."); } delay(100); // Short delay to debounce the button } receiver code : #include <SPI.h> #include "RF24.h" #define CE_PIN 9 #define CSN_PIN 10 #define LED_PIN 3 RF24 radio(CE_PIN, CSN_PIN); const byte address[6] = "00001"; void setup() { Serial.begin(115200); pinMode(LED_PIN, OUTPUT); radio.begin(); radio.openReadingPipe(0, address); radio.setPALevel(RF24_PA_LOW); radio.startListening(); } void loop() { if (radio.available()) { bool buttonState; radio.read(&buttonState, sizeof(buttonState)); if (buttonState) { digitalWrite(LED_PIN, HIGH); // Turn LED on Serial.println("LED ON"); } else { digitalWrite(LED_PIN, LOW); // Turn LED off Serial.println("LED OFF"); } } }
code : const int buttonPin = 2; // Pin connected to the button const int mosfetPin = 9; // Pin connected to the MOSFET gate unsigned long lastButtonPressTime = 0; bool motorRunning = false; void setup() { pinMode(buttonPin, INPUT_PULLUP); // Set the button pin as input with internal pull-up resistor pinMode(mosfetPin, OUTPUT); // Set the MOSFET pin as output } void loop() { int buttonState = digitalRead(buttonPin); // Read the state of the button if (buttonState == LOW && !motorRunning) { // If the button is pressed and motor is not running digitalWrite(mosfetPin, HIGH); // Turn the motor on motorRunning = true; lastButtonPressTime = millis(); // Record the time of button press } else if (buttonState == HIGH && motorRunning) { // If the button is released and motor is running digitalWrite(mosfetPin, LOW); // Turn the motor off motorRunning = false; } }
code : #include <Wire.h> #include <Adafruit_GFX.h> #include <Adafruit_SSD1306.h> #include <EEPROM.h> // For saving the timer state #define SCREEN_WIDTH 128 #define SCREEN_HEIGHT 64 #define OLED_RESET -1 Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET); const int clockPin = 2; // Pin connected to the 555 timer output const int resetButtonPin = 3; // Pin connected to the reset button const int startButtonPin = 4; // Pin connected to the start/pause button const int setButtonPin = 5; // Pin connected to the set timer button const int buzzerPin = 6; // Pin connected to the buzzer volatile unsigned long pulseCount = 0; bool timerRunning = false; bool timerPaused = false; unsigned long setTime = 0; // For setting the timer unsigned long lastDebounceTime = 0; unsigned long debounceDelay = 50; void setup() { pinMode(clockPin, INPUT); pinMode(resetButtonPin, INPUT_PULLUP); pinMode(startButtonPin, INPUT_PULLUP); pinMode(setButtonPin, INPUT_PULLUP); pinMode(buzzerPin, OUTPUT); attachInterrupt(digitalPinToInterrupt(clockPin), countPulse, RISING); if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { Serial.println(F("SSD1306 allocation failed")); for (;;); } display.clearDisplay(); display.setTextSize(1); display.setTextColor(SSD1306_WHITE); display.setCursor(0, 0); display.display(); // Load saved state from EEPROM pulseCount = EEPROM.read(0); timerRunning = EEPROM.read(1); timerPaused = EEPROM.read(2); updateDisplay(); } void loop() { handleButtons(); if (timerRunning && !timerPaused) { updateDisplay(); } if (pulseCount == 0 && timerRunning) { timerRunning = false; tone(buzzerPin, 1000, 1000); // Sound buzzer for 1 second } delay(100); // Update the display every 100ms } void handleButtons() { unsigned long currentMillis = millis(); if (currentMillis - lastDebounceTime >= debounceDelay) { if (digitalRead(resetButtonPin) == LOW) { pulseCount = 0; timerRunning = false; timerPaused = false; updateDisplay(); lastDebounceTime = currentMillis; // Reset debounce timer saveState(); // Save current state to EEPROM } if (digitalRead(startButtonPin) == LOW) { if (timerRunning && !timerPaused) { timerPaused = true; } else if (timerRunning && timerPaused) { timerPaused = false; } else { timerRunning = true; } updateDisplay(); lastDebounceTime = currentMillis; // Reset debounce timer saveState(); // Save current state to EEPROM } if (digitalRead(setButtonPin) == LOW) { setTime++; pulseCount = setTime * 60; // Set the time in seconds updateDisplay(); lastDebounceTime = currentMillis; // Reset debounce timer saveState(); // Save current state to EEPROM } } } void countPulse() { if (timerRunning && !timerPaused) { pulseCount++; } } void updateDisplay() { unsigned long totalSeconds = pulseCount; unsigned long minutes = totalSeconds / 60; unsigned long seconds = totalSeconds % 60; display.clearDisplay(); display.setCursor(0, 0); display.setTextSize(2); display.print("Timer: "); if (minutes < 10) display.print("0"); display.print(minutes); display.print(":"); if (seconds < 10) display.print("0"); display.print(seconds); display.setTextSize(1); display.setCursor(0, 32); display.print("Status: "); if (timerRunning) { if (timerPaused) { display.print("Paused"); } else { display.print("Running"); } } else { display.print("Stopped"); } display.display(); } void saveState() { EEPROM.write(0, pulseCount); EEPROM.write(1, timerRunning); EEPROM.write(2, timerPaused); }
code : #include <IRremote.h> #include <Wire.h> #include <Adafruit_GFX.h> #include <Adafruit_SSD1306.h> #define SCREEN_WIDTH 128 // OLED display width, in pixels #define SCREEN_HEIGHT 64 // OLED display height, in pixels #define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin) Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET); const int irReceiverPin = 2; // IR receiver pin IRrecv irrecv(irReceiverPin); decode_results results; // Define LED pins const int ledPins[] = {8, 9, 10, 11, 12, 13}; // Adjust pins as needed bool ledStates[] = {false, false, false, false, false, false}; // Store LED states // Define a structure to hold IR code and corresponding action struct IRCommand { unsigned long code; const char *description; }; // Array of IR commands const IRCommand commands[] = { {0xBA45FF00, "Button 1 pressed"}, {0xB946FF00, "Button 2 pressed"}, {0xB847FF00, "Button 3 pressed"}, {0xBB44FF00, "Button 4 pressed"}, {0xBF40FF00, "Button 5 pressed"}, {0xBC43FF00, "Button 6 pressed"}, {0xE619FF00, "Button 0 pressed"}, // Turn off all LEDs {0xF807FF00, "Button 7 pressed"}, // Pattern 1 {0xEA15FF00, "Button 8 pressed"}, // Pattern 2 {0xF609FF00, "Button 9 pressed"}, // Pattern 3 {0xE916FF00, "Star (*) pressed"}, {0xF20DFF00, "Hashtag (#) pressed"}, {0xE718FF00, "Arrow Up pressed"}, {0xAD52FF00, "Arrow Down pressed"}, {0xF708FF00, "Arrow Left pressed"}, {0xA55AFF00, "Arrow Right pressed"}, {0xE31CFF00, "OK pressed"}, }; bool patternActive = false; int currentPattern = 0; void setup() { Serial.begin(9600); irrecv.enableIRIn(); if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { Serial.println(F("SSD1306 allocation failed")); for (;;); } display.clearDisplay(); display.setTextSize(1); display.setTextColor(SSD1306_WHITE); display.setCursor(0, 0); display.println("IR Remote Control"); display.display(); // Initialize LED pins for (int i = 0; i < 6; i++) { pinMode(ledPins[i], OUTPUT); digitalWrite(ledPins[i], LOW); // Turn off all LEDs initially } } void displayLedStates() { display.clearDisplay(); display.setCursor(0, 0); for (int i = 0; i < 6; i++) { display.print("LED "); display.print(i + 1); display.print(": "); display.println(ledStates[i] ? "ON" : "OFF"); } display.display(); } void setPattern(int pattern) { switch (pattern) { case 1: // Alternating LEDs (odd LEDs ON, even LEDs OFF) for (int i = 0; i < 6; i++) { ledStates[i] = (i % 2 == 0); digitalWrite(ledPins[i], ledStates[i]); } break; case 2: // Blinking all LEDs for (int j = 0; j < 5; j++) { // Blink 5 times for (int i = 0; i < 6; i++) { ledStates[i] = !ledStates[i]; digitalWrite(ledPins[i], ledStates[i]); } delay(500); // Half a second delay } break; case 3: // Chasing light effect for (int i = 0; i < 6; i++) { ledStates[i] = false; // Turn off all LEDs initially digitalWrite(ledPins[i], LOW); } patternActive = true; // Set pattern active currentPattern = 3; // Set current pattern to chasing effect break; } displayLedStates(); } void loop() { if (irrecv.decode()) { unsigned long irCode = irrecv.decodedIRData.decodedRawData; if (irCode == 0xFFFFFFFF) { // Ignore the repeat code irrecv.resume(); // Receive the next value return; } Serial.println(irCode, HEX); display.clearDisplay(); display.setCursor(0, 0); display.print("Code: "); display.println(irCode, HEX); bool commandFound = false; // Check the received code against the array of commands for (size_t i = 0; i < sizeof(commands) / sizeof(commands[0]); i++) { if (irCode == commands[i].code) { display.setCursor(0, 20); display.println(commands[i].description); // Toggle the respective LED based on button 1-6 if (i >= 0 && i < 6) { patternActive = false; // Stop any running pattern int ledPin = ledPins[i]; ledStates[i] = !ledStates[i]; digitalWrite(ledPin, ledStates[i]); // Toggle the LED state } else if (irCode == 0xE619FF00) { // Button 0 pressed patternActive = false; // Stop any running pattern // Turn off all LEDs for (int j = 0; j < 6; j++) { ledStates[j] = false; digitalWrite(ledPins[j], LOW); } } else if (irCode == 0xF609FF00) { // Button 9 pressed (Pattern 3) patternActive = false; // Stop any running pattern setPattern(3); // Activate Pattern 3 } else if (irCode == 0xEA15FF00) { // Button 8 pressed (Pattern 2) patternActive = false; // Stop any running pattern setPattern(2); // Activate Pattern 2 } else if (irCode == 0xF807FF00) { // Button 7 pressed (Pattern 1) patternActive = false; // Stop any running pattern setPattern(1); // Activate Pattern 1 } commandFound = true; break; } } displayLedStates(); irrecv.resume(); // Receive the next value } if (patternActive && currentPattern == 3) { // Chasing light effect logic static int chaseIndex = 0; digitalWrite(ledPins[chaseIndex], LOW); // Turn off current LED chaseIndex = (chaseIndex + 1) % 6; // Move to next LED digitalWrite(ledPins[chaseIndex], HIGH); // Turn on next LED delay(250); // Adjust the delay for chase speed } }
Tazmanya görmesin
code : #include <Wire.h> #include <Adafruit_GFX.h> #include <Adafruit_SSD1306.h> #include <BfButton.h> // Define pins for rotary encoder and LEDs int btnPin = 3; // Push button pin on encoder int DT = 4; // DT pin (Output B) of encoder int CLK = 5; // CLK pin (Output A) of encoder int ledPins[6] = {8, 9, 10, 11,12,13}; // Pins for 6 LEDs BfButton btn(BfButton::STANDALONE_DIGITAL, btnPin, true, LOW); int angle = 0; int aState; int aLastState; // Initialize OLED display with appropriate I2C address #define SCREEN_WIDTH 128 #define SCREEN_HEIGHT 64 #define OLED_RESET -1 Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET); void setup() { Serial.begin(9600); pinMode(CLK, INPUT_PULLUP); pinMode(DT, INPUT_PULLUP); aLastState = digitalRead(CLK); // Initialize LED pins as outputs for (int i = 0; i < 6; i++) { pinMode(ledPins[i], OUTPUT); } // Initialize OLED display if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3C for 128x64 Serial.println(F("SSD1306 allocation failed")); for (;;) ; } display.clearDisplay(); display.setTextColor(SSD1306_WHITE); display.setTextSize(1); display.setCursor(0, 0); display.println("Press button"); angle = 0; // Initialize angle to 0 updateOLED(angle); // Update OLED with initial angle // Button settings btn.onPress([](BfButton *btn, BfButton::press_pattern_t pattern) { if (pattern == BfButton::SINGLE_PRESS) { angle = 50; // Set angle to 50% brightness updateLEDs(angle); // Update LED brightness updateOLED(angle); // Update OLED display } }); } void loop() { btn.read(); // Check button state aState = digitalRead(CLK); // Encoder rotation tracking if (aState != aLastState) { if (digitalRead(DT) != aState) { angle+=2; } else { angle-=2; } // Ensure angle stays within 0 to 100 range if (angle < 0) { angle = 0; } else if (angle > 100) { angle = 100; } updateLEDs(angle); // Update LEDs based on current angle updateOLED(angle); // Update OLED display with current angle Serial.println(angle); // Print angle for debugging } aLastState = aState; } // Function to update LED brightness based on angle (0-100) void updateLEDs(int ang) { // Map angle to LED brightness (0-255) int ledBrightness = map(ang, 0, 100, 0, 255); // Set LED brightness for (int i = 0; i < 6; i++) { analogWrite(ledPins[i], ledBrightness); } } // Function to update OLED display with percentage void updateOLED(int ang) { display.clearDisplay(); display.setCursor(0, 0); display.print("LED Percentage:"); display.setCursor(0, 10); display.print(ang); display.print("%"); display.display(); }
code : #include <Wire.h> #include <OneWire.h> #include <DallasTemperature.h> #include <Adafruit_GFX.h> #include <Adafruit_SSD1306.h> #define ONE_WIRE_BUS 2 // Data wire is connected to digital pin 2 on Arduino OneWire oneWire(ONE_WIRE_BUS); DallasTemperature sensors(&oneWire); #define OLED_RESET 4 Adafruit_SSD1306 display(OLED_RESET); const int buzzerPin = 8; // Buzzer connected to digital pin 8 float thresholdTemperature = 50.0; // Temperature threshold in Celsius to activate buzzer void setup() { Serial.begin(9600); sensors.begin(); // Initialize buzzer pin pinMode(buzzerPin, OUTPUT); // Initialize OLED display with I2C address 0x3C if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { Serial.println(F("SSD1306 allocation failed")); for (;;); } // Clear the display display.clearDisplay(); display.display(); } void loop() { sensors.requestTemperatures(); // Send the command to get temperature readings float tempC = sensors.getTempCByIndex(0); // Read temperature in Celsius if (tempC != DEVICE_DISCONNECTED_C) { float tempF = tempC * 9.0 / 5.0 + 32.0; // Convert Celsius to Fahrenheit // Print temperature to Serial monitor Serial.print("Temperature: "); Serial.print(tempC); Serial.print(" °C, "); Serial.print(tempF); Serial.println(" °F"); // Display temperature on OLED display.clearDisplay(); display.setTextSize(1); display.setTextColor(SSD1306_WHITE); display.setCursor(0, 0); display.print("Temp: "); display.print(tempC); display.print(" C / "); display.print(tempF); display.println(" F"); display.display(); // Check if temperature exceeds threshold to activate buzzer if (tempC > thresholdTemperature) { tone(buzzerPin, 1000); // Generate a tone of 1000Hz on buzzerPin } else { noTone(buzzerPin); // Stop the tone } } else { Serial.println("Error: Could not read temperature data"); } delay(1000); // Wait for a second }
Ce dracu ai coaie te crezi electroboom
code: // Define Connections to 74HC595 // ST_CP pin 12 const int latchPin = 10; // SH_CP pin 11 const int clockPin = 11; // DS pin 14 const int dataPin = 12; void setup() { // Setup pins as Outputs pinMode(latchPin, OUTPUT); pinMode(clockPin, OUTPUT); pinMode(dataPin, OUTPUT); } void loop() { // Move the LED from left to right for (int i = 0; i < 8; i++) { digitalWrite(latchPin, LOW); shiftOut(dataPin, clockPin, MSBFIRST, 1 << i); digitalWrite(latchPin, HIGH); delay(200); } // Move the LED from right to left for (int i = 7; i >= 0; i--) { digitalWrite(latchPin, LOW); shiftOut(dataPin, clockPin, MSBFIRST, 1 << i); digitalWrite(latchPin, HIGH); delay(200); } }
english or spanish ahh song
hahahahahaah
this use of the NE555 is in astable mode, which continuously oscillates between its high and low states
code: #include <IRremote.h> #include <Wire.h> #include <Adafruit_GFX.h> #include <Adafruit_SSD1306.h> #define SCREEN_WIDTH 128 // OLED display width, in pixels #define SCREEN_HEIGHT 64 // OLED display height, in pixels #define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin) Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET); const int irReceiverPin = 13; // IR receiver pin IRrecv irrecv(irReceiverPin); decode_results results; // Define a structure to hold IR code and corresponding action struct IRCommand { unsigned long code; const char *description; }; // Array of IR commands const IRCommand commands[] = { {0xBA45FF00, "Button 1 pressed"}, {0xB946FF00, "Button 2 pressed"}, {0xB847FF00, "Button 3 pressed"}, {0xBB44FF00, "Button 4 pressed"}, {0xBF40FF00, "Button 5 pressed"}, {0xBC43FF00, "Button 6 pressed"}, {0xF807FF00, "Button 7 pressed"}, {0xEA15FF00, "Button 8 pressed"}, {0xF609FF00, "Button 9 pressed"}, {0xE916FF00, "Star (*) pressed"}, {0xE619FF00, "Button 0 pressed"}, {0xF20DFF00, "Hashtag (#) pressed"}, {0xE718FF00, "Arrow Up pressed"}, {0xAD52FF00, "Arrow Down pressed"}, {0xF708FF00, "Arrow Left pressed"}, {0xA55AFF00, "Arrow Right pressed"}, {0xE31CFF00 , "OK pressed "}, }; void setup() { Serial.begin(9600); irrecv.enableIRIn(); if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { Serial.println(F("SSD1306 allocation failed")); for(;;); } display.clearDisplay(); display.setTextSize(1); display.setTextColor(SSD1306_WHITE); display.setCursor(0, 0); display.println("IR Remote Control"); display.display(); } void loop() { if (irrecv.decode()) { unsigned long irCode = irrecv.decodedIRData.decodedRawData; if (irCode == 0xFFFFFFFF) { // Ignore the repeat code irCode = 0; // Set to 0 or last valid code as per your logic } Serial.println(irCode, HEX); display.clearDisplay(); display.setCursor(0, 0); display.println("IR Remote Control"); display.setCursor(0, 20); display.print("Code: "); display.println(irCode, HEX); bool commandFound = false; // Check the received code against the array of commands for (size_t i = 0; i < sizeof(commands) / sizeof(commands[0]); i++) { if (irCode == commands[i].code) { display.setCursor(0, 40); display.println(commands[i].description); commandFound = true; break; } } if (!commandFound) { display.setCursor(0, 40); display.println("Unknown Button"); } display.display(); irrecv.resume(); // Receive the next value } }
Glory to Ukraine
Сколько китайских роботов и прочих разработок 😂😂😂
code: #include <Wire.h> #include <Adafruit_GFX.h> #include <Adafruit_SSD1306.h> // Define OLED reset pin #define OLED_RESET 4 Adafruit_SSD1306 display(OLED_RESET); // Define Ultrasonic sensor pins const int trigPin = 9; const int echoPin = 10; // Define Buzzer pin const int buzzerPin = 7; // Define distance thresholds (in centimeters) const int veryCloseThreshold = 5; const int closeThreshold = 10; const int safeThreshold = 20; const int farThreshold = 30; void setup() { // Initialize serial communication Serial.begin(9600); // Initialize the OLED display if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { Serial.println(F("SSD1306 allocation failed")); for (;;); } display.clearDisplay(); display.display(); // Initialize ultrasonic sensor and buzzer pins pinMode(trigPin, OUTPUT); pinMode(echoPin, INPUT); pinMode(buzzerPin, OUTPUT); // Print initial debug message Serial.println("Setup complete. Starting measurement..."); } void loop() { // Measure distance using ultrasonic sensor long duration; int distance; digitalWrite(trigPin, LOW); delayMicroseconds(2); digitalWrite(trigPin, HIGH); delayMicroseconds(10); digitalWrite(trigPin, LOW); duration = pulseIn(echoPin, HIGH); distance = duration * 0.034 / 2; // Debug statement for distance Serial.print("Measured duration: "); Serial.print(duration); Serial.print(" microseconds, calculated distance: "); Serial.print(distance); Serial.println(" cm"); // Display distance and warning message on OLED display.clearDisplay(); display.setTextSize(1); display.setTextColor(SSD1306_WHITE); display.setCursor(0, 0); display.print("Distance: "); display.print(distance); display.println(" cm"); // Determine warning message and buzzer behavior based on distance if (distance > 0 && distance < veryCloseThreshold) { tone(buzzerPin, 2500); // Higher frequency for very close display.setCursor(0, 10); display.println("Warning: VERY CLOSE!"); Serial.println("Buzzer ON - VERY CLOSE!"); } else if (distance >= veryCloseThreshold && distance < closeThreshold) { tone(buzzerPin, 1500); display.setCursor(0, 10); display.println("Warning: Close"); Serial.println("Buzzer ON - Close!"); } else if (distance >= closeThreshold && distance < safeThreshold) { noTone(buzzerPin); display.setCursor(0, 10); display.println("Status: Safe"); Serial.println("Buzzer OFF - Safe distance."); } else if (distance >= safeThreshold && distance < farThreshold) { noTone(buzzerPin); // Turn off the buzzer display.setCursor(0, 10); display.println("Status: Far"); Serial.println("Buzzer OFF - Far distance."); } else { noTone(buzzerPin); // Turn off the buzzer display.setCursor(0, 10); display.println("Status: Very Far"); Serial.println("Buzzer OFF - Very far distance."); } display.display(); delay(100); // Delay between measurements }
Cool video man keep it up
code : #include <Adafruit_GFX.h> #include <Adafruit_SSD1306.h> // OLED display settings #define SCREEN_WIDTH 128 #define SCREEN_HEIGHT 64 #define OLED_RESET -1 Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET); // Button pins const int startStopButtonPin = 2; const int resetButtonPin = 3; bool running = false; unsigned long startTime; unsigned long elapsedTime; void setup() { Serial.begin(9600); // For debugging // Initialize the display if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Fixed address initialization Serial.println(F("SSD1306 allocation failed")); for(;;); } display.display(); delay(2000); display.clearDisplay(); // Initialize buttons with external pull-down resistors pinMode(startStopButtonPin, INPUT); pinMode(resetButtonPin, INPUT); } void loop() { // Check if start/stop button is pressed if (digitalRead(startStopButtonPin) == HIGH) { delay(200); // Debounce delay running = !running; if (running) { startTime = millis() - elapsedTime; } else { elapsedTime = millis() - startTime; } } // Check if reset button is pressed if (digitalRead(resetButtonPin) == HIGH) { delay(200); // Debounce delay running = false; elapsedTime = 0; } // Update the display display.clearDisplay(); display.setTextSize(2); display.setTextColor(SSD1306_WHITE); display.setCursor(0, 10); unsigned long currentTime = running ? millis() - startTime : elapsedTime; int seconds = (currentTime / 1000) % 60; int minutes = (currentTime / (1000 * 60)) % 60; int hours = (currentTime / (1000 * 60 * 60)) % 24; display.print(hours < 10 ? "0" : ""); display.print(hours); display.print(":"); display.print(minutes < 10 ? "0" : ""); display.print(minutes); display.print(":"); display.print(seconds < 10 ? "0" : ""); display.print(seconds); display.display(); delay(100); }
code : #include <OneWire.h> #include <DallasTemperature.h> // Data wire is plugged into port 2 on the Arduino #define ONE_WIRE_BUS 2 // Setup a oneWire instance to communicate with any OneWire devices OneWire oneWire(ONE_WIRE_BUS); // Pass our oneWire reference to Dallas Temperature DallasTemperature sensors(&oneWire); // Array to hold device address DeviceAddress insideThermometer; // Define RGB pins const int redPin = 9; const int greenPin = 10; const int bluePin = 11; void setup(void) { Serial.begin(9600); // Start up the library sensors.begin(); // Assign address manually or use search if (!sensors.getAddress(insideThermometer, 0)) Serial.println("Unable to find address for Device 0"); // set the resolution to 9 bit sensors.setResolution(insideThermometer, 9); Serial.print("Device 0 Address: "); printAddress(insideThermometer); Serial.println(); Serial.print("Device 0 Resolution: "); Serial.print(sensors.getResolution(insideThermometer), DEC); Serial.println(); // Set RGB pins as outputs pinMode(redPin, OUTPUT); pinMode(greenPin, OUTPUT); pinMode(bluePin, OUTPUT); } void loop(void) { // Request temperature sensors.requestTemperatures(); float tempC = sensors.getTempC(insideThermometer); if (tempC != DEVICE_DISCONNECTED_C) { Serial.print("Temperature: "); Serial.print(tempC); Serial.println(" °C"); // Map temperature to HSV color float hue = map(tempC, 27.5, 34, 240, 0); // Map temperature to hue (blue to red) float saturation = 1.0; // Set saturation to maximum float value = 1.0; // Set value to maximum // Convert HSV to RGB float c = value * saturation; float x = c * (1 - abs(fmod(hue / 60.0, 2) - 1)); float m = value - c; float red = 0, green = 0, blue = 0; if (hue >= 0 && hue < 60) { red = c; green = x; } else if (hue >= 60 && hue < 120) { red = x; green = c; } else if (hue >= 120 && hue < 180) { green = c; blue = x; } else if (hue >= 180 && hue < 240) { green = x; blue = c; } else if (hue >= 240 && hue < 300) { red = x; blue = c; } else if (hue >= 300 && hue < 360) { red = c; blue = x; } // Set RGB values analogWrite(redPin, red * 255); analogWrite(greenPin, green * 255); analogWrite(bluePin, blue * 255); } else { Serial.println("Error: Could not read temperature data"); } delay(1000); // Delay between readings } // Function to print a device address void printAddress(DeviceAddress deviceAddress) { for (uint8_t i = 0; i < 8; i++) { if (deviceAddress[i] < 16) Serial.print("0"); Serial.print(deviceAddress[i], HEX); } }
code : const int buttonPin = 2; const int redPin = 9; const int greenPin = 10; const int bluePin = 11; int buttonState = 0; int lastButtonState = 0; int colorIndex = -1; // Start with -1 to keep the LED off initially void setup() { pinMode(buttonPin, INPUT_PULLUP); // Use internal pull-up resistor pinMode(redPin, OUTPUT); pinMode(greenPin, OUTPUT); pinMode(bluePin, OUTPUT); Serial.begin(9600); // Initialize serial communication // Initialize the RGB LED to off setColor(0, 0, 0); // Print initial message Serial.println("Debugging Initialized..."); } void loop() { buttonState = digitalRead(buttonPin); // Print button state Serial.print("Button State: "); Serial.println(buttonState); if (buttonState == LOW && lastButtonState == HIGH) { // Button has been pressed Serial.println("Button Pressed!"); colorIndex = (colorIndex + 1) % 7; Serial.print("Color Index: "); Serial.println(colorIndex); changeColor(colorIndex); delay(50); // Debounce delay } lastButtonState = buttonState; delay(100); // Optional delay for serial output readability } void changeColor(int index) { switch (index) { case 0: setColor(255, 0, 0); // Red break; case 1: setColor(0, 255, 0); // Green break; case 2: setColor(0, 0, 255); // Blue break; case 3: setColor(255, 255, 0); // Yellow break; case 4: setColor(0, 255, 255); // Cyan break; case 5: setColor(255, 0, 255); // Magenta break; case 6: setColor(255, 255, 255); // White break; } } void setColor(int red, int green, int blue) { analogWrite(redPin, red); analogWrite(greenPin, green); analogWrite(bluePin, blue); }
Thx
And I have a question, are you Romanian?
Can You give the code pls 🥺
code: const int pirPin = 2; // PIR motion sensor pin const int ledPins[] = {3, 4, 5, 6, 7}; // LED pins const int ledCount = 5; void setup() { pinMode(pirPin, INPUT); for (int i = 0; i < ledCount; i++) { pinMode(ledPins[i], OUTPUT); digitalWrite(ledPins[i], LOW); // Ensure all LEDs are off at the start } } void loop() { int motionDetected = digitalRead(pirPin); if (motionDetected == HIGH) { for (int i = 0; i < ledCount; i++) { digitalWrite(ledPins[i], HIGH); delay(100); // Delay to create the intermittent effect digitalWrite(ledPins[i], LOW); delay(100); // Delay to create the intermittent effect } } else { for (int i = 0; i < ledCount; i++) { digitalWrite(ledPins[i], LOW); } } }
Cool, I also use arduino but not arduino jade instead I use uno nano and pro mini but it's still interesting
this jade is just an arduino mega made by a different manufacturer thanks to its open source feature
@@chupacabra1899 cool
And i do use arduino mega
code: const int echo = 13; const int trig = 12; int LED1 = 2; int duration = 0; int distance = 0; void setup() { pinMode(trig, OUTPUT); pinMode(echo, INPUT); pinMode(LED1, OUTPUT); Serial.begin(9600); } void loop() { digitalWrite(trig, HIGH); delayMicroseconds(10); digitalWrite(trig, LOW); digitalWrite(LED1, LOW); duration = pulseIn(echo, HIGH); distance = (duration / 2) / 28.5; if (distance < 20) { digitalWrite(LED1, HIGH); Serial.print("Distance : "); Serial.println(distance); int blinkDelay = map(distance, 0, 1, 50, 220); delay(blinkDelay); digitalWrite(LED1, LOW); delay(blinkDelay); } }
code : const int greenPin = 9; const int redPin = 10; const int bluePin = 11; const int echoPin = 13; const int trigPin = 12; void setup() { pinMode(redPin, OUTPUT); pinMode(greenPin, OUTPUT); pinMode(bluePin, OUTPUT); pinMode(trigPin, OUTPUT); pinMode(echoPin, INPUT); Serial.begin(9600); } void loop() { // Trigger ultrasonic sensor digitalWrite(trigPin, LOW); delayMicroseconds(2); digitalWrite(trigPin, HIGH); delayMicroseconds(10); digitalWrite(trigPin, LOW); // Read ultrasonic sensor long duration = pulseIn(echoPin, HIGH); int distance = duration * 0.034 / 2; Serial.print("Distance: "); Serial.println(distance); // Set RGB color based on distance if (distance < 5) { // Red light RGB_output(255, 0, 0); delay(2000); } else if (distance >= 5 && distance < 15) { // Yellow light RGB_output(255, 255, 0); delay(2000); } else { // Green light RGB_output(0, 255, 0); delay(2000); } } void RGB_output(int redLight, int greenLight, int blueLight) { analogWrite(redPin, redLight); analogWrite(greenPin, greenLight); analogWrite(bluePin, blueLight); }
code: int LED1 = 13; int LED2 = 12; int LED3 = 11; void setup() { pinMode(LED1, OUTPUT); pinMode(LED2, OUTPUT); pinMode(LED3, OUTPUT); } void loop() { digitalWrite(LED1, HIGH); // turn on LED1 delay(200); // wait for 200ms digitalWrite(LED2, HIGH); // turn on LED2 delay(200); // wait for 200ms digitalWrite(LED3, HIGH); // turn on LED3 delay(200); // wait for 200ms digitalWrite(LED1, LOW); // turn off LED1 delay(300); // wait for 300ms digitalWrite(LED2, LOW); // turn off LED2 delay(300); // wait for 300ms digitalWrite(LED3, LOW); // turn off LED3 delay(300); // wait for 300ms before running program all over again }
I did the same but I copied a large part of blink
ce faci coaie
did 107.5 the other day and 105 with a pause. will do jonnie candito 6 week strength programme
could have probably done 9 if i had music
I got a question. - Is it good to preform a lift at your double wieght in bench press "RAW" (at a amature level) and are over 40+ years old) ? - It is common that competion persons (VM etc.) can do/lift their own double weight in bench press. Example: Your weight: 80 kg Bench press one time (MAX) at 160 kg
I am not an expert by any means, but I think as long as your using good form,sleeping,having good nutrition and not trying to max out every week you should be ok
good stuff homie I hit that sub and hit that like button. Looking forward to more vids from you
thanks ! be sure to see more milestones :)
nice bro, i just hit 100kg 2 days ago, im also 18 and been training 6 months. good progress
thanks ! keep the grind going 💪
Really good, I'm 42 and still keep it up after 24 years of training.
Salut man , ai facut video-ul acesta in 2015 ! acum 6 ani mai pe scurt , si lumea inca mai joaca metin2 , sigur nu cum se juca inainte dar totusi . set-urile astea inca le fac , desi n am mai jucat metin de 3 ani .. oricum sper sa mi poti raspunde la video si sa postezi curand un videoclip cu war uri .