Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
1.9 kB
1
Indexable
Never
//Potentometer
/*
#define PassiveBuzzerPin 3
#define LED_RED 4
#define LED_GREEN 5
#define LED_BLUE 6
#define LED_YELLOW 7
#define KNOB_PIN A0
#define NOTE_M1  523

void setup()
{
    pinMode(LED_RED, OUTPUT);
    pinMode(LED_GREEN, OUTPUT);
    pinMode(LED_BLUE, OUTPUT);
    pinMode(LED_YELLOW, OUTPUT);
    Serial.begin(9600);
}
void loop()
{
    int KnobValue = analogRead(KNOB_PIN);
    int brightness = KnobValue / 0.2;
    analogWrite(LED_RED, brightness);
    analogWrite(LED_GREEN, brightness);
    analogWrite(LED_BLUE, brightness);
    analogWrite(LED_YELLOW, brightness);

    if (brightness <= 0)
    {
        tone(3, 349, 100);//F4
        delay(100);
        return;
    }
}
*/

// LDR

#define LED_RED 4
#define LED_GREEN 5
#define LED_BLUE 6
#define LED_YELLOW 7
#define ldrPin A2
#define PassiveBuzzerPin 3

void setup() {
    pinMode(LED_RED, OUTPUT);
    pinMode(LED_GREEN, OUTPUT);
    pinMode(LED_BLUE, OUTPUT);
    pinMode(LED_YELLOW, OUTPUT);
    pinMode(ldrPin, INPUT);
    Serial.begin(9600);
}

void loop() {
    int ldrStatus = analogRead(ldrPin);
    if (ldrStatus <= 600) {
        delay(100);
        digitalWrite(LED_RED, HIGH);
        digitalWrite(LED_GREEN, HIGH);
        digitalWrite(LED_BLUE, HIGH);
        digitalWrite(LED_YELLOW, HIGH);
        Serial.print("Its DARK, Turn on the LED : ");
        Serial.println(ldrStatus);
    }
    else {
        delay(100);
        digitalWrite(LED_RED, LOW);
        digitalWrite(LED_GREEN, LOW);
        digitalWrite(LED_BLUE, LOW);
        digitalWrite(LED_YELLOW, LOW);
        tone(3, 349, 100);//F4
        Serial.print("Its BRIGHT, Turn off the LED : ");
        Serial.println(ldrStatus);
    }
}