LDR Sensor activates Buzzer using a Seeeduino Xiao

Description: A Light Dependent Resistor (LDR) connected to a Seeeduino Xiao is used to activate/deactivate a buzzer when the light levels have changed.

Supplies:

1 –  Breadboard 830 Points
1 – Seeeduino Xiao
1 – Piezo Buzzer  >> Link <<
1 – Light Dependent Resistor (LDR)   >> Link << 
1 – 220 Ohm Resistor

Arduino Code:

const int LDR = A6;
int input_val = 0;
const int buzzer = 3;

void setup() {
  
  Serial.begin(115200);
  pinMode(buzzer, OUTPUT);

}

void loop() {
  
  input_val = analogRead(LDR);
  Serial.print("LDR Value is: ");
  Serial.println(input_val);
  delay(100);

  if (input_val > 1020) {
  tone(buzzer, 300);
  delay(100);
  noTone(buzzer);
  delay(100);

}

}

Leave a Comment

+ 15 = 21