Build a sleek Arduino-powered Tabletop Weather Station and turn your DIY into a pro-grade IoT device with JUSTWAY!
To make the experience fit your profile, pick a username and tell us what interests you.
We found and based on your interests.
Wiring the LDR SensorCreate a voltage divider
This setup gives the Arduino a changing voltage that represents brightness.
Wiring the Relay Module
LEDStripPower
For a 12v LED Strip:
The relay will switch the strip ON/OFF by controlling the ground connection.
Use the Arduino IDE The sketch below reads the LDR, checks if it's dark, and switches the relay.
// Beginner-friendly: Read button on pin 6 and control a relay on pin 2
// Wiring (recommended):
// - Relay module VCC -> 5V
// - Relay module GND -> GND
// - Relay module IN -> Arduino digital pin 2
// - Button one side -> Arduino pin 6
// - Button other side -> GND
// Note: This sketch uses INPUT_PULLUP, so button connects to GND when pressed.
const int RELAY_PIN = 2; // Relay control pin
const int BUTTON_PIN = 7; // Input pin (button or switch)
// If your relay module is "active LOW" (common for many modules), set true.
// If your relay turns ON when IN is HIGH, set false.
const bool RELAY_ACTIVE_LOW = false;
void setup() {
Serial.begin(9600); // Optional: debug output to Serial Monitor
pinMode(RELAY_PIN, OUTPUT); // Relay pin is an output
pinMode(BUTTON_PIN, INPUT_PULLUP); // Use the internal pull-up resistor
// Make sure relay starts OFF
if (RELAY_ACTIVE_LOW) digitalWrite(RELAY_PIN, HIGH); // HIGH -> off for active-low relay
else digitalWrite(RELAY_PIN, LOW); // LOW -> off for active-high relay
Serial.println("Ready. Press the button to turn the relay ON.");
}
//Made By Rohan Barnwal
void loop() {
// Read the button. Because of INPUT_PULLUP, pressed == LOW.
int raw = digitalRead(BUTTON_PIN);
bool pressed = (raw == LOW); // true when button is pressed
// Simple debounce: when we detect a press state change, wait briefly and re-read.
static bool lastPressed = false;
if (pressed != lastPressed) {
delay(30); // small debounce delay (30 ms)
raw = digitalRead(BUTTON_PIN);
pressed = (raw == LOW);
lastPressed = pressed;
}
// Turn relay on or off based on button
if (pressed) {
// Turn relay ON
if (RELAY_ACTIVE_LOW) digitalWrite(RELAY_PIN, LOW); // active-low -> LOW turns ON
else digitalWrite(RELAY_PIN, HIGH); // active-high -> HIGH turns ON
Serial.println("Relay: ON");
} else {
// Turn relay OFF
if (RELAY_ACTIVE_LOW) digitalWrite(RELAY_PIN, HIGH); // active-low -> HIGH turns OFF
else digitalWrite(RELAY_PIN, LOW); // active-high -> LOW turns OFF
Serial.println("Relay: OFF");
}
delay(100); // small loop delay to avoid flooding Serial
}Your breadboard prototype may work perfectly, but looks like a tech spaghetti bowl.
When you want to impress at a science fair, competition, or investor meeting presentation is everything.
That's where JUSTWAY comes in.
JUSTWAY helps you transform your DIY project into a professional grade prototype, complete with a custom enclosure, metal finish, or injection-molded body - ready for the world to see.
Pro Tip: Want your circuit look futuristic?
You now have a simple and reliable automatic lighting controller using an LDR, relay, and Arduino UNO Mini. This system is great for bedrooms, hallways, stair lighting, or outdoor decorative LEDs. By combining this with a 3D-printed housing from JUSTWAY, you can turn a hobby build into a neat, durable, professional-looking device.
Create an account to leave a comment. Already have an account? Log In.
Become a member to follow this project and never miss any updates
About Us Contact Hackaday.io Give Feedback Terms of Use Privacy Policy Hackaday API Do not sell or share my personal information