Simple Arduino project for beginners. Magic Harp

Поділитися
Вставка
  • Опубліковано 29 чер 2024
  • #arduino #breadboard #project #electronic #engineering #funny #laser
    In todays video we make a simple magic harp project via LDR, Lasers and arduino

КОМЕНТАРІ • 2

  • @LeviathanEngineering
    @LeviathanEngineering  День тому

    Code:
    const int LDR_PIN1 = A1; // Analog pin connected to the first three-pin LDR module
    const int LDR_PIN2 = A2; // Analog pin connected to the second three-pin LDR module
    const int LDR_PIN3 = A3; // Analog pin connected to the third three-pin LDR module
    const int LDR_PIN4 = A4; // Analog pin connected to the fourth three-pin LDR module
    const int LDR_PIN5 = A5; // Analog pin connected to the fifth three-pin LDR module
    const int BUZZER_PIN = 9; // Digital pin connected to buzzer
    const int LASER_PIN = 2; // Digital pin connected to laser diode
    void setup() {
    pinMode(LDR_PIN1, INPUT);
    pinMode(LDR_PIN2, INPUT);
    pinMode(LDR_PIN3, INPUT);
    pinMode(LDR_PIN4, INPUT);
    pinMode(LDR_PIN5, INPUT);
    pinMode(BUZZER_PIN, OUTPUT);
    pinMode(LASER_PIN, OUTPUT);
    digitalWrite(LASER_PIN, HIGH); // Turn on the laser diode
    Serial.begin(9600);
    }
    void loop() {
    int LDRValue1 = analogRead(LDR_PIN1); // Read the value from the first LDR module
    int LDRValue2 = analogRead(LDR_PIN2); // Read the value from the second LDR module
    int LDRValue3 = analogRead(LDR_PIN3); // Read the value from the third LDR module
    int LDRValue4 = analogRead(LDR_PIN4); // Read the value from the fourth LDR module
    int LDRValue5 = analogRead(LDR_PIN5); // Read the value from the fifth LDR module
    Serial.print("LDR1: ");
    Serial.print(LDRValue1);
    Serial.print(", LDR2: ");
    Serial.print(LDRValue2);
    Serial.print(", LDR3: ");
    Serial.print(LDRValue3);
    Serial.print(", LDR4: ");
    Serial.print(LDRValue4);
    Serial.print(", LDR5: ");
    Serial.println(LDRValue5);
    if (LDRValue1 < 800) { // Adjust the threshold value for LDR1 as needed
    tone(BUZZER_PIN, 400); // Play a tone of 400Hz for LDR1
    } else if (LDRValue2 < 800) { // Adjust the threshold value for LDR2 as needed
    tone(BUZZER_PIN, 500); // Play a tone of 500Hz for LDR2
    } else if (LDRValue3 < 800) { // Adjust the threshold value for LDR3 as needed
    tone(BUZZER_PIN, 600); // Play a tone of 600Hz for LDR3
    } else if (LDRValue4 < 800) { // Adjust the threshold value for LDR4 as needed
    tone(BUZZER_PIN, 700); // Play a tone of 700Hz for LDR4
    } else if (LDRValue5 < 800) { // Adjust the threshold value for LDR5 as needed
    tone(BUZZER_PIN, 800); // Play a tone of 800Hz for LDR5
    } else {
    noTone(BUZZER_PIN); // Stop playing tone if no LDR is triggered
    }
    delay(100); // Small delay to stabilize readings
    }

  • @user-zb7ff4fi1e
    @user-zb7ff4fi1e 2 дні тому

    Yoo that’s craaaazy