so here is the code int LDR = A0; // LDR analog pin int Buzzer = 9; // Buzzer pin (Arduino pin D9) int RLED = 7; // Red LED pin (Arduino pin D7) int BLED = 6; // Blue LED pin (Arduino pin D6) int PushButton = 5; // Push button pin (Arduino pin D5) int LDRVal = 0; bool buzzerActive = false; // Flag to track buzzer state void setup() { Serial.begin(9600); pinMode(LDR, INPUT); pinMode(Buzzer, OUTPUT); pinMode(RLED, OUTPUT); pinMode(BLED, OUTPUT); pinMode(PushButton, INPUT_PULLUP); // Enable internal pull-up resistor for the button } void loop() { LDRVal = analogRead(LDR); Serial.println(LDRVal); // Print LDR value to Serial Monitor // Check if LDR value is below a threshold (673) to activate the buzzer if (LDRVal < 673 && !buzzerActive) { // LDR intensity is below threshold and buzzer is not active buzzerActive = true; // Activate the buzzer digitalWrite(Buzzer, HIGH); // Turn on buzzer tone(Buzzer, 500, 500); // Generate tone at 500Hz for 500ms digitalWrite(RLED, HIGH); // Turn on red LED delay(500); digitalWrite(RLED, LOW); // Turn off red LED digitalWrite(BLED, HIGH); // Turn on blue LED delay(500); digitalWrite(BLED, LOW); // Turn off blue LED } // Read the state of the push button bool buttonPressed = digitalRead(PushButton) == LOW; // Check if button is pressed (inverted due to INPUT_PULLUP) // Check if the push button is pressed to stop the buzzer if (buttonPressed && buzzerActive) { buzzerActive = false; // Deactivate the buzzer digitalWrite(Buzzer, LOW); // Turn off buzzer digitalWrite(RLED, LOW); // Turn off red LED digitalWrite(BLED, LOW); // Turn off blue LED } delay(100); // Delay for stability } and here is tinkercad link www.tinkercad.com/things/9v0IkzmwNJZ-copy-of-iot-laser-security-breach/editel?sharecode=DJCBuNGght1hTVH_AIzKQ31fFcpLDsXZX06tx8dKW-4
Can u plz share code
Yes Thambi, I have added the link for code in the description
@@CRAIGANDREWURKAI Thanks Anna
भैया इसका code share करो please
I have added the link for code in the description
the code is different in video and in the link
please can you give the code which is there in the video?
oops
It was a year back bro, idk lol
@@CRAIGANDREWURKAI no problem!!
so here is the code
int LDR = A0; // LDR analog pin
int Buzzer = 9; // Buzzer pin (Arduino pin D9)
int RLED = 7; // Red LED pin (Arduino pin D7)
int BLED = 6; // Blue LED pin (Arduino pin D6)
int PushButton = 5; // Push button pin (Arduino pin D5)
int LDRVal = 0;
bool buzzerActive = false; // Flag to track buzzer state
void setup() {
Serial.begin(9600);
pinMode(LDR, INPUT);
pinMode(Buzzer, OUTPUT);
pinMode(RLED, OUTPUT);
pinMode(BLED, OUTPUT);
pinMode(PushButton, INPUT_PULLUP); // Enable internal pull-up resistor for the button
}
void loop() {
LDRVal = analogRead(LDR);
Serial.println(LDRVal); // Print LDR value to Serial Monitor
// Check if LDR value is below a threshold (673) to activate the buzzer
if (LDRVal < 673 && !buzzerActive) {
// LDR intensity is below threshold and buzzer is not active
buzzerActive = true; // Activate the buzzer
digitalWrite(Buzzer, HIGH); // Turn on buzzer
tone(Buzzer, 500, 500); // Generate tone at 500Hz for 500ms
digitalWrite(RLED, HIGH); // Turn on red LED
delay(500);
digitalWrite(RLED, LOW); // Turn off red LED
digitalWrite(BLED, HIGH); // Turn on blue LED
delay(500);
digitalWrite(BLED, LOW); // Turn off blue LED
}
// Read the state of the push button
bool buttonPressed = digitalRead(PushButton) == LOW; // Check if button is pressed (inverted due to INPUT_PULLUP)
// Check if the push button is pressed to stop the buzzer
if (buttonPressed && buzzerActive) {
buzzerActive = false; // Deactivate the buzzer
digitalWrite(Buzzer, LOW); // Turn off buzzer
digitalWrite(RLED, LOW); // Turn off red LED
digitalWrite(BLED, LOW); // Turn off blue LED
}
delay(100); // Delay for stability
}
and here is tinkercad link
www.tinkercad.com/things/9v0IkzmwNJZ-copy-of-iot-laser-security-breach/editel?sharecode=DJCBuNGght1hTVH_AIzKQ31fFcpLDsXZX06tx8dKW-4
Can u share this code plz
I have added the link for code in the description
Can i get the code for this
I have added the link for code in the description
cypher found
wrong code in the link
Can you share code please
I have added the link for code in the description