Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
/********* Pleasedontcode.com ********** Pleasedontcode thanks you for automatic code generation! Enjoy your code! - Terms and Conditions: You have a non-exclusive, revocable, worldwide, royalty-free license for personal and commercial use. Attribution is optional; modifications are allowed, but you're responsible for code maintenance. We're not liable for any loss or damage. For full terms, please visit pleasedontcode.com/termsandconditions. - Project: "Arduino Alarm" - Source Code compiled for: Arduino Uno - Source Code created on: 2024-01-03 08:28:08 ********* Pleasedontcode.com **********/ /****** SYSTEM REQUIREMENTS *****/ /****** SYSTEM REQUIREMENT 1 *****/ /* Turn on buzzer when distance sensor detects an */ /* object nearby */ /****** END SYSTEM REQUIREMENTS *****/ /****** DEFINITION OF LIBRARIES *****/ #include
#include
#include
/****** SYSTEM REQUIREMENTS *****/ /****** SYSTEM REQUIREMENT 1 *****/ /* Turn on buzzer when distance sensor detects an */ /* object nearby */ /****** END SYSTEM REQUIREMENTS *****/ /****** FUNCTION PROTOTYPES *****/ void setup(void); void loop(void); /***** DEFINITION OF DIGITAL INPUT PINS *****/ const uint8_t distance_sensor_HC_SR04_Echo_PIN_D3 = 3; /***** DEFINITION OF DIGITAL OUTPUT PINS *****/ const uint8_t distance_sensor_HC_SR04_Trigger_PIN_D2 = 2; const uint8_t buzzer_PassiveBuzzer_Signal_PIN_D4 = 4; /****** DEFINITION OF LIBRARY CLASS INSTANCES*****/ Ultrasonic ultrasonic(distance_sensor_HC_SR04_Trigger_PIN_D2, distance_sensor_HC_SR04_Echo_PIN_D3); ezBuzzer buzzer(buzzer_PassiveBuzzer_Signal_PIN_D4); void setup(void) { // put your setup code here, to run once: pinMode(distance_sensor_HC_SR04_Echo_PIN_D3, INPUT); pinMode(distance_sensor_HC_SR04_Trigger_PIN_D2, OUTPUT); pinMode(buzzer_PassiveBuzzer_Signal_PIN_D4, OUTPUT); } void loop(void) { // put your main code here, to run repeatedly: // Read distance from ultrasonic sensor unsigned int distance = ultrasonic.read(); // Check if object is nearby if (distance < 20) { // Adjust the threshold distance as per your requirement // Turn on the buzzer buzzer.beep(200); // Adjust the beep time duration as per your requirement } // Add any other code for your system requirements here delay(100); // Adjust the delay time as per your requirement }
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)