BiotronicMaikerVideotronicMaker
Published © CC BY-NC

Bioluminescent Night Light with LED Proxy (Version 1.4)

This project simulates a bioluminescent night light using LEDs and a photoresistor.

BeginnerFull instructions provided30 minutes243
Bioluminescent Night Light with LED Proxy (Version 1.4)

Things used in this project

Hardware components

Arduino Nano v3
Seeed Studio Arduino Nano v3
×1
Jumper wires (generic)
Jumper wires (generic)
×1
5 mm LED: Red
5 mm LED: Red
×1
5 mm LED: Green
5 mm LED: Green
×1
Photo resistor
Photo resistor
×1
Resistor 220 ohm
Resistor 220 ohm
×2
Resistor 1k ohm
Resistor 1k ohm
×1
Solderless Breadboard Half Size
Solderless Breadboard Half Size
×1
USB-A to Mini-USB Cable
USB-A to Mini-USB Cable
×1
Jumper wires (generic)
Jumper wires (generic)
×1

Story

Read more

Schematics

Layout

Code

biolum_night_light_LEDproxy_V1.4.ino

Arduino
This project simulates a bioluminescent night light using LEDs and a photoresistor. An LED acts as a proxy for bioluminescent bacteria, turning on and off at set intervals.
A photoresistor detects the light from the "bacteria" LED.
When the "bacteria" LED is on and the ambient light is low, a second LED (the "night light") is activated.
/*
  Bioluminescent Night Light with LED Proxy (Version 1.4)
  BiotronikMAiker

  This project simulates a bioluminescent night light using LEDs and a photoresistor.
  An LED acts as a proxy for bioluminescent bacteria, turning on and off at set intervals.
  A photoresistor detects the light from the "bacteria" LED.
  When the "bacteria" LED is on and the ambient light is low, a second LED (the "night light") is activated.

  This code was generated with the assistance of Gemini, an AI assistant, under the guidance and direction of BiotronikMAiker and VideotronicMaker. 
  It is part of a larger project exploring the integration of bioluminescence, Arduino, and AI.

  Circuit:
  - Bacteria LED (e.g., white or yellow) connected to digital pin 3.
  - Night Light LED (e.g., green) connected to digital pin 2.
  - Photoresistor connected to analog pin A0.

  Version 1 - Prototype without Bacteria:
  An LED simulates the bioluminescent bacteria. The light sensor/photoresistor detects the light from these initial LEDs.
  This triggers the Arduino to activate a single LED to indicate that light was sensed.

  Modifications by: VideotronicMaker (Instructor)
  Date: [January 7, 2025]
*/

// Pin definitions
const int bacteriaLedPin = 3;     // Digital pin connected to the "bacteria" LED (simulating bacteria)
const int nightLightLedPin = 2;   // Digital pin connected to the "night light" LED (indicator)
const int photoresistorPin = A0;  // Analog pin connected to the photoresistor

// Timing constants (in milliseconds)
const unsigned long onTime = 3000;   // Time the "bacteria" LED stays on (3 seconds)
const unsigned long offTime = 2000;  // Time the "bacteria" LED stays off (2 seconds)

// Light threshold for the photoresistor.
// Adjust this value based on your photoresistor and ambient lighting conditions.
const int lightThreshold = 500;

// Variable to store the last time the "bacteria" LED was updated
unsigned long previousMillis = 0;

// Variable to track the state of the "bacteria" LED (on or off)
bool bacteriaLedState = HIGH;  // Start with the "bacteria" LED ON

void setup() {
  // Initialize the "bacteria" LED pin as an output.
  pinMode(bacteriaLedPin, OUTPUT);

  // Initialize the "night light" LED pin as an output.
  pinMode(nightLightLedPin, OUTPUT);

  // Turn on the "bacteria" LED initially.
  digitalWrite(bacteriaLedPin, HIGH);
}

void loop() {
  // Get the current time in milliseconds.
  unsigned long currentMillis = millis();

  // --- Bacteria LED Control ---

  // Check if the "bacteria" LED is currently ON and if the 'onTime' duration has elapsed.
  if (bacteriaLedState == HIGH && currentMillis - previousMillis >= onTime) {
    // Update 'previousMillis' to the current time.
    previousMillis = currentMillis;

    // Change the state of the "bacteria" LED to OFF.
    bacteriaLedState = LOW;

    // Turn OFF the "bacteria" LED.
    digitalWrite(bacteriaLedPin, bacteriaLedState);
  }
  // Otherwise, check if the "bacteria" LED is currently OFF and if the 'offTime' duration has elapsed.
  else if (bacteriaLedState == LOW && currentMillis - previousMillis >= offTime) {
    // Update 'previousMillis' to the current time.
    previousMillis = currentMillis;

    // Change the state of the "bacteria" LED to ON.
    bacteriaLedState = HIGH;

    // Turn ON the "bacteria" LED.
    digitalWrite(bacteriaLedPin, bacteriaLedState);
  }

  // --- Photoresistor Reading ---

  // Read the analog value from the photoresistor.
  int lightLevel = analogRead(photoresistorPin);

  // --- Night Light LED Control ---

  // Check if the light level is below the threshold AND the "bacteria" LED is ON.
  if (lightLevel < lightThreshold && bacteriaLedState == HIGH) {
    // Turn ON the "night light" LED.
    digitalWrite(nightLightLedPin, HIGH);
  } else {
    // Turn OFF the "night light" LED.
    digitalWrite(nightLightLedPin, LOW);
  }
}

Credits

BiotronicMaiker
2 projects • 2 followers
Contact
VideotronicMaker
10 projects • 8 followers
A co-worker told me about Arduino. I researched it all and I was fascinated by what I saw. I have now begun my journey as a maker.
Contact

Comments

Please log in or sign up to comment.