Sir Boateng Online
No Result
View All Result
  • TECH & ELECTRONICS
    • Arduino Projects
    • Proteus
    • Applied Electricity
  • TUTORIALS
    • Blogging
  • EDUCATION
    • GES Resources
    • NTC Resources
    • Scholarships
    • Universities & Colleges
  • REVIEWS
    • Comparisons
  • MORE
    • Contact Us
    • Disclosure Statement
    • Disclaimer
    • Privacy Policy
Friday, May 9, 2025
  • TECH & ELECTRONICS
    • Arduino Projects
    • Proteus
    • Applied Electricity
  • TUTORIALS
    • Blogging
  • EDUCATION
    • GES Resources
    • NTC Resources
    • Scholarships
    • Universities & Colleges
  • REVIEWS
    • Comparisons
  • MORE
    • Contact Us
    • Disclosure Statement
    • Disclaimer
    • Privacy Policy
No Result
View All Result
Sir Boateng Online
No Result
View All Result
Home Electronics

Automatic Stair Light – Proteus Simulation

Sir Boat by Sir Boat
15th November 2023
Reading Time: 7 mins read
492 26
13
automatic stair light image

automatic stair light image

Buy all your electronics, STEM, Robotics and IoT products and sensors from DIYgh TECH HUB diygh.com Buy all your electronics, STEM, Robotics and IoT products and sensors from DIYgh TECH HUB diygh.com Buy all your electronics, STEM, Robotics and IoT products and sensors from DIYgh TECH HUB diygh.com
ADVERTISEMENT

In this edition of our regular Arduino and Proteus tutorials, we have once again come out with a very cool project called Automatic Stair light Simulation in Proteus 8.11. This Do-it-yourself intelligent (sensor or manual activated) stair lighting from HomeMade Electronics lights up your stairs automatically when you enter the staircase area. This project saves energy and reduces your electricity bill.

The actual project (Automatic stair light system) uses Arduino Nano and Ultrasonic sensors. However, due to simulation and simplicity, the ultrasonic sensor has been replaced with push buttons. You can click here or request the ultrasonic version in the comment section.

Download Project Files

Automatic Stair Light designed and simulated in Proteus. The system detects the presence of humans and lights up the LEDs in sequential order. The real constructed system makes use of Arduino Uno and an ultrasonic or motion sensor for automatic detection.

However, I used two push buttons to construct this automatic stair light as you can see from the video below for simulation purposes which can also be physically implemented with real functional components. For code and diagram of the project with either an ultrasonic sensor or motion sensor, kindly leave a comment.

Also, check these Projects:

  • Arduino Sensor Libraries for Proteus Simulation (Updated)
  • Automatic Water Level Monitor & Controller in Proteus | Step By Step With Arduino Source Code
  • Proteus 8.11 Latest Version Download For Free
  • Proteus 8.12 Latest Version Download for Free
  • Arduino 4-Way Traffic System with Pedestrian button in Proteus

When the circuit is activated, it lights the LEDs sequentially, starting from where the user is detected. So for instance, if the user is climbing up the stairs, the LEDs will start illuminating from the base of the stairs and gradually move to the top.

As soon as the user reaches the top, the sensor detects the presence and triggers the system to turn off the LEDs again starting from the bottom.

This automatic stair light can be configured from the Arduino code to change the speed at which the LEDs transition from the ON state to the OFF. To edit the speed, you can refer to the code below:

 int tOn = 300; //LED On delay
 int tOff = 4000; //LED Off delay

Check the video demonstration of the project below:

https://www.youtube.com/watch?v=Jnmv760xiUk

Table of Contents

  • Arduino Code
  • Code explanation of the Automatic Stair Light
  • Related Posts
  • How to Fix Common Issues on TM1 Laptops – Expert Tips
  • Download TM1 Laptop Drivers
  • TM1 Laptop Specs & FAQ: A Detailed Review

Arduino Code

const int ledPins[] = {13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2};
const int numLeds = sizeof(ledPins) / sizeof(ledPins[0]);
const int bUpPin = A0;
const int bDownPin = A5;
const int tOn = 300;
const int tOff = 4000;
unsigned activeUp = 0;
unsigned activeDown = 0;
void setup() {
  Serial.begin(9600);
  Serial.println("Activated");
  for (int i = 0; i < numLeds; i++) {
    pinMode(ledPins[i], OUTPUT);
  }
  pinMode(bUpPin, INPUT_PULLUP);
  pinMode(bDownPin, INPUT_PULLUP);
  Serial.println("Pins set");
  Serial.print("active up: ");
  Serial.println(activeUp);
  Serial.print("active down: ");
  Serial.println(activeDown);
  Serial.println("Variables set");
  Serial.println("Ready");
}
void loop() {
  int up = digitalRead(bUpPin);
  int down = digitalRead(bDownPin);
  if (up == LOW) {
    Serial.println("Bottom button pressed!");
    if (activeUp == 1 || activeDown == 1) {
      Serial.println("System active!");
      offDown();
    } else {
      Serial.println("System activated (up)");
      onUp();
    }
  }
  if (down == LOW) {
    Serial.println("Top button pressed");
    if (activeUp == 1 || activeDown == 1) {
      Serial.println("System active!");
      offUp();
    } else {
      Serial.println("System activated (down)");
      onDown();
    }
  }
}
void setLeds(bool state) {
  for (int i = 0; i < numLeds; i++) {
    digitalWrite(ledPins[i], state);
    delay(state ? tOn : tOff);
  }
}
void onUp() {
  Serial.println("Switching on lights (up)");
  setLeds(HIGH);
  activeUp = 1;
  Serial.print("active up: ");
  Serial.println(activeUp);
  Serial.print("active down: ");
  Serial.println(activeDown);
  Serial.println("System now active (up)");
}
void offUp() {
  Serial.println("Switching lights off (Up)");
  setLeds(LOW);
  activeUp = 0;
  activeDown = 0;
  Serial.print("active up: ");
  Serial.println(activeUp);
  Serial.print("active down: ");
  Serial.println(activeDown);
  Serial.println("System not active");
}
void onDown() {
  Serial.println("Switching lights on (down)");
  setLeds(HIGH);
  activeDown = 1;
  Serial.print("active up: ");
  Serial.println(activeUp);
  Serial.print("active down: ");
  Serial.println(activeDown);
  Serial.println("System now active (down)");
}
void offDown() {
  Serial.println("Switching lights off (down)");
  setLeds(LOW);
  activeUp = 0;
  activeDown = 0;
  Serial.print("active up: ");
  Serial.println(activeUp);
  Serial.print("active down: ");
  Serial.println(activeDown);
  Serial.println("System not active");
}

Code explanation of the Automatic Stair Light

Now let’s go through the code step by step so that you will understand how the system works:

Related Posts

How to Fix Common Issues on TM1 Laptops – Expert Tips

Download TM1 Laptop Drivers

TM1 Laptop Specs & FAQ: A Detailed Review

const int ledPins[] = {13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2};
const int numLeds = sizeof(ledPins) / sizeof(ledPins[0]);

In this part of the code, we define an array ledPins to hold the pin numbers of the LEDs and numLeds to store the number of LEDs in the array.

const int bUpPin = A0;
const int bDownPin = A5;

Here, we define constants for the button pin numbers for better readability.

const int tOn = 300;
const int tOff = 4000;

These constants represent the delay times for turning the LEDs on and off.

unsigned activeUp = 0;
unsigned activeDown = 0;

We define two unsigned integer variables to track whether the system is active going upward (activeUp) or downwards (activeDown).

void setup() {
  // ...
}

The setup() function is where the initial setup of the Arduino happens.

void loop() {
  // ...
}

The loop() function is where the main logic of your program runs repeatedly.

Inside the loop() function, we read the state of the buttons:

int up = digitalRead(bUpPin);
int down = digitalRead(bDownPin);

We read the state of the buttons using digitalRead() and store the result in the variables up and down.

if (up == LOW) {
  // ...
}

If the bottom button (up) is pressed (LOW state), we check whether the system is already active going upwards or downwards. If it’s active, we turn off the lights using the appropriate function (offDown()). Otherwise, we activate the system going upwards (onUp()).

if (down == LOW) {
  // ...
}

If the top button (down) is pressed (LOW state), we follow a similar logic as above, but this time for activating the system going downwards (onDown()) or turning off the lights going downwards (offUp()).

The functions onUp(), offUp(), onDown(), and offDown() are responsible for controlling the LEDs based on the selected direction. They use the setLeds() function to turn the LEDs on or off sequentially, with appropriate delays.

The code structure and logic in these functions are similar, so I’ll explain one as an example:

void onUp() {
  Serial.println("Switching on lights (up)");
  setLeds(HIGH);
  activeUp = 1;
  Serial.print("active up: ");
  Serial.println(activeUp);
  Serial.print("active down: ");
  Serial.println(activeDown);
  Serial.println("System now active (up)");
}

In the onUp() function:

  1. We print a message to indicate that the lights are being switched ON and going upwards.
  2. We call the setLeds(HIGH) function to turn the LEDs on.
  3. We set the activeUp variable to 1 to indicate that the system is now active and going upwards.
  4. We print the values of activeUp and activeDown.
  5. We print a message to indicate that the system is now active and going upwards.

The offUp(), onDown(), and offDown() functions follow a similar pattern but with their respective operations.

I believe you now understand how the code works. If you encounter any problems, or if you need help constructing this automatic stair light project, leave a comment below.

Join Our Tech & Edu Forum
Tags: Automatic Stair Lightproteus simulation
Share237Tweet148Send
Buy all your electronics, STEM, Robotics and IoT products and sensors from DIYgh TECH HUB diygh.com Buy all your electronics, STEM, Robotics and IoT products and sensors from DIYgh TECH HUB diygh.com Buy all your electronics, STEM, Robotics and IoT products and sensors from DIYgh TECH HUB diygh.com
Sir Boat

Sir Boat

Boateng Oduro is passionate about learning new technologies and working on them. He is a teacher and an engineer who loves to read, write, and teach. He's always curious about things and very determined to track the latest technologies and the trends for the future.

Related Posts

How to fix TM1 laptop
TM1 Laptop

How to Fix Common Issues on TM1 Laptops – Expert Tips

19th July 2023
A picture showing how to Download all TM1 Laptop Drivers
TM1 Laptop

Download TM1 Laptop Drivers

19th July 2023
TM1 Laptop Specs & FAQ: A Detailed Review
TM1 Laptop

TM1 Laptop Specs & FAQ: A Detailed Review

19th July 2023
An image showing the Top 10 Best Website Hosting Providers in 2023 to choose from.
Blogging

Top 10 Hosting Providers in 2023 – Find the Best One for Your Website

5th September 2023
A picture of grammarly premium and grammerly free, get grammarly premium cookies for free - grammarly premium cookies daily updates free download - use grammarly premium free.png
Tutorials

How to Get Grammarly Premium Cookies for Free in 2023

5th September 2023
A picture of grammarly premium and grammerly free, get grammarly premium cookies for free - grammarly premium cookies daily updates free download - use grammarly premium free.png
Blogging

Get Grammarly premium for free using Cookies

26th December 2024
Next Post
How to fix TM1 laptop

How To Fix TM1 Laptop Sound Drivers

tm1 laptop drivers

How to install all TM1 Laptop drivers

Comments 13

  1. Nana Yaw says:
    3 years ago

    Please Could you be so kind as to share the code and diagram of the Automatic Stair Light project with either an ultrasonic sensor or motion sensor with me?

    Reply
    • Nana Yaw says:
      3 years ago

      I learn more on here about embedded systems and electronics, than anywhere else, for which I’m grateful to you.

      Reply
      • Sir Boat says:
        3 years ago

        Can you tell me the Arduino pins you want to use for the ultrasonic sensor?
        Specifically, the Echo and Trigger pins. Or if you want me to decide the pins myself, let me know.

        Reply
        • Nana Yaw says:
          3 years ago

          It would be best if you decided that Sir.

          Reply
        • Nana Yaw says:
          3 years ago

          Hello Sir

          Reply
          • Sir Boat says:
            2 years ago

            Hello Nana Yaw

          • Sir Boat says:
            1 year ago

            I have written a complete articles on that at: https://lizbotech.com/how-to-make-automatic-stair-lights-with-arduino-and-ultrasonic-sensor/
            Check it out

  2. Mahmoud Ahmed says:
    2 years ago

    i want the nature of work ….How it works?

    Reply
    • Sir Boat says:
      2 years ago

      The real system detects the presence of humans and turns ON the stairs light. When the person climbs or descends, the system automatically turns OFF the lights.

      Reply
  3. Yatin says:
    2 years ago

    What changes should I make in the code section to turn on only lights of two steps ahead only and turn off previous stairs lights as I move ahead, and what should be added in case someone has fallen off from stairs?
    It would be a great help if you suggest what changes should I make.

    Reply
    • Sir Boat says:
      2 years ago

      Do you mean to turn the light on or off based on the user’s location? If so then there should be separate sensors for each step.

      Reply
  4. joel villatoro says:
    2 years ago

    que cabios devo haser para poner los censores?

    Reply
    • Sir Boat says:
      2 years ago

      ¿Quieres decir con sensores ultrasónicos reales?

      Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Buy all your electronics, STEM, Robotics and IoT products and sensors from DIYgh TECH HUB diygh.com Buy all your electronics, STEM, Robotics and IoT products and sensors from DIYgh TECH HUB diygh.com Buy all your electronics, STEM, Robotics and IoT products and sensors from DIYgh TECH HUB diygh.com
ADVERTISEMENT

Categories

  • Applied Electricity & Electronics (4)
  • Arduino Projects (8)
  • Blogging (3)
  • Comparisons (3)
  • Education (34)
  • Electronics (21)
  • GES Resources (19)
  • NTC Resources (8)
  • Product and Service Reviews (6)
  • Proteus (2)
  • Scholarships (2)
  • TM1 Laptop (7)
  • Tutorials (18)
  • Universities & Colleges (8)
Buy all your electronics, STEM, Robotics and IoT products and sensors from DIYgh TECH HUB diygh.com Buy all your electronics, STEM, Robotics and IoT products and sensors from DIYgh TECH HUB diygh.com Buy all your electronics, STEM, Robotics and IoT products and sensors from DIYgh TECH HUB diygh.com
ADVERTISEMENT

About Us

Sir Boateng Online is a platform for technology and electronic projects, tutorials, and educational resources. Aside from creating Tech tutorials, we provide Education, GES, and NTC resources such as teaching syllabi, lesson notes, scheme of work, GES promotion, and NTC trial questions. We help people, especially DIY enthusiasts, to create websites for blogging, businesses, and organizations such as schools, churches, clubs, etc.

Popular Categories

Applied Electricity & Electronics Arduino Projects Blogging Comparisons Education Electronics GES Resources NTC Resources Product and Service Reviews Proteus Scholarships TM1 Laptop Tutorials Universities & Colleges

Search for Articles

No Result
View All Result

Stay Connected

Follow Us

Subscribe to receive updates
  • About Me
  • Disclaimer
  • Privacy Policy
  • Terms and Conditions

© 2023 Sir Boateng Online by Lizbotech Engineering

Welcome Back!

Login to your account below

Forgotten Password?

Retrieve your password

Please enter your username or email address to reset your password.

Log In
No Result
View All Result
  • TECH & ELECTRONICS
    • Arduino Projects
    • Proteus
    • Applied Electricity
  • TUTORIALS
    • Blogging
  • EDUCATION
    • GES Resources
    • NTC Resources
    • Scholarships
    • Universities & Colleges
  • REVIEWS
    • Comparisons
  • MORE
    • Contact Us
    • Disclosure Statement
    • Disclaimer
    • Privacy Policy

© 2023 Sir Boateng Online by Lizbotech Engineering