This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Servo.h> | |
const int TRIG_PIN = 9; | |
const int ECHO_PIN = 10; | |
const int SERVO_PIN = 3; | |
const int LED_PIN = 6; | |
// --- Door angles --- | |
const int DOOR_CLOSED_ANGLE = 90; // closed at 90° | |
const int DOOR_OPEN_ANGLE = 0; // open at 0° |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Arduino Project: Fast Beeping Active Buzzer with Potentiometer | |
// Author: YASHASH BM | |
int buzzer = 8; // Active buzzer connected to D8 | |
int pot = A0; // Potentiometer connected to A0 | |
void setup() { | |
pinMode(buzzer, OUTPUT); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define trigPin 9 | |
#define echoPin 10 | |
// Street light LEDs (you can add/remove pins here) | |
int leds[] = {3, 4, 5, 6, 7}; | |
int ledCount = 5; | |
long duration; | |
int distance; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Servo.h> | |
Servo myServo; | |
const int potPin = A0; // potentiometer middle pin | |
const int servoPin = 9; // servo signal pin | |
// SG90 safe pulse range | |
const int minPWM = 500; // ~0° | |
const int maxPWM = 2400; // ~160-170° |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Servo.h> | |
Servo lidServo; | |
int trigPin = 2; | |
int echoPin = 3; | |
int servoPin = 9; | |
long duration; | |
int distance; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int ledPins[] = {2, 3, 4, 5}; | |
int ledCount = 4; | |
void setup() { | |
for (int i = 0; i < ledCount; i++) { | |
pinMode(ledPins[i], OUTPUT); | |
digitalWrite(ledPins[i], LOW); | |
} | |
randomSeed(analogRead(A0)); // use A0 as seed | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int probePin = 2; // Probe input | |
int buzzer = 3; // Buzzer output | |
void setup() { | |
pinMode(probePin, INPUT_PULLUP); // Keep pin HIGH until water touches | |
pinMode(buzzer, OUTPUT); | |
} | |
void loop() { | |
int water = digitalRead(probePin); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 4-light staircase with HC-SR04 (500 ms step delay, 5s hold time) | |
const int trigPin = 9; | |
const int echoPin = 10; | |
const int leds[] = {2, 3, 4, 5}; // 4 LEDs | |
const unsigned long holdTime = 5000UL; // keep lights on this long after last detection (5 seconds) | |
const unsigned long stepDelay = 500UL; // delay between lighting each LED (500 ms) | |
const int detectDistance = 50; // cm threshold | |
unsigned long lastDetectTime = 0; |