Introduction: Basic Night Light With Arduino

This is a very basic tutorial for creating a night light with an Arduino Uno unit. Everything that is used here comes straight out of the box. Below is a link to the Arduino used in this project. You can perform this, and other experiments, with what is provided in the kit:

https://smile.amazon.com/gp/product/B01D8KOZF4/ref...

(Grade Range: 6-8 grades)

Supplies

1 - Arduino Uno kit ($38.99 as of 10/11)

From the kit you will need:

1 - Arduino Uno unit

1 - BREAD board

6 - Wires

1 - 10k Ohm Resistor

1 - 220 Ohm Resistor

1 - LED light

1 - Photocell

(OPTIONAL) 1 pair of needle-nosed pliers.

Step 1: STEL's Relationship

Before diving into the project, it is important to relate back to the Standards of Technology and Engineering Literacy handbook. Students should be able to see the relevance of the project as far as how it relates to school-work. In the handbook, there is one key core disciplinary standard, practice, and context that this project ties to:

Core Disciplinary Standard:

- Core Concept of Technology and Engineering

The driving principle behind this standard is to emphasize to students the idea of an Engineering or Technological system. A system is a group of interrelated components designed collectively to achieve a desired goal. In our example here, we have a variety of components that are coming together to make a working piece of technology (albeit on a very basic level).

At the 6-8 grade levels, students should be able to:

STEL-2M: Differentiate between inputs, processes, outputs, and feedback in technological systems. In this design specifically, students need to be able to understand the information that the Arduino is feeding to the user so that they can properly set values in the code for the program to work properly.

STEL-2P: Create a closed-loop system that has a feedback path and requires no human intervention. Because of the system we are creating, we need the Arduino to take in information and then respond/react back in a specific way. The information we are using at this point is the amount of light our photocell is receiving.

Technology and Engineering Practices:

- Making and Doing (TEP-3)

Because this is a very hands-on project, it leaves a lot of different approaches for the student to take to solve this problem.

Another aspect of Making and Doing that needs to be emphasize is safety in operating with tools and equipment. Because we are working with electricity, there is a potential chance of electric shock. Users who wish to do this Instructable should follow the setup and instructions exactly. This is so that wiring doesn't go awry and cause damage to the Arduino, the BREAD board, the electronics, or, most importantly, the user.

Technology and Engineering Context:

- Computation, Automation, AI, and Robotics (TEC - 1)

While our work with computers is minimal, we are still working with code. Because of this, we are by definition programing the Arduino. As we work with the code, be sure to pay attention to the values that are being given, and adjust your code as needed.

While working with your ARDUINO UNO, you are also fulfilling:

STEL-1J: Developing an innovative product/system that solves problems and extends capabilities based on individual/collective need. We are solving the issue of not being able to see in the dark, which we fix with the creation of this night-light.

STEL-2P: Create a closed loop system that has a feedback path and requires no human intervention. We have already reviewed how this applies to our system here, so we won't review it again.

Step 2: Getting Started

Let's start by talking about the learning objectives:

- For users to learn the basics of coding in Arduino.

- For users to be able to use basic wiring skills to create a photocell sensor and a night light

- For users to interpret data and make adjustments to code as needed to set up the Arduino night light properly.

In order to do this project, we need to begin by examining what each major component does that we are working with.

The center of our project revolves around the Arduino Board. You can think of it like a miniature, simplified computer. The Arduino is hooked up to a larger, more complex computer, and code is written within the Arduino programming to give the smaller board a list of instructions to follow. Once this is done, the code is uploaded to the board, where the board follows those instructions. On a basic level, Arduino boards receive inputs, and then spit out an output, based on how we program it. Simple!

Next is the photo cell. The photo cell is able to detect light entering into it, and it gives off a signal that the Arduino can read. We will want to know the values that the photocell is generating, both when it is under a light source and has no shading on it at all, and when there is a shadow over it.

Third we have a resistor. Resistors are used to reduce the flow of current through an electrical system. In our two setups that we use, resistors are placed so that our more delicate electrical components don't get damaged or overloaded from higher amounts of electricity passing through them.

Lastly is our LED light. LED, or light emitting diodes, generate light when current passes through it. Electrons in the semiconductor recombine with electron holes, releasing energy in the form of photons ().

**SOURCES:

- Arduino Board = https://www.arduino.cc/en/guide/introduction

- Photocell = https://learn.adafruit.com/photocells

- Resistor = https://en.wikipedia.org/wiki/Resistor

- LED light = https://en.wikipedia.org/wiki/Light-emitting_diode

Step 3: Start Assembly!

We will start by putting a wire from the 5V slot (5 Volt) into an empty slot on the bread board.

Step 4: Follow-up Wiring

Next, we will want to add our 10k Ohm resistor (10 kilo Ohm) to the BREAD board, in line with the 5V line. We add the photocell to the board after this, with one end of the photocell hooking up to the end of the resistor that isn't on the same line as the wire. Be sure to leave a gap between the resistor and the photocell!

Step 5: More Wires!

From here, we want to go ahead and grab another wire to ground our system before we hook any kind of power up to the Arduino. We then want to gather information coming from the photocell, so we will also add a wire to one of the analog slots. In this case, we will pick A0 (Analog 0 slot). This will read the information coming off of the photocell.

Step 6: Data Collection / Code

Above, we see the code used for this project, along with the data coming in from the photocell.

We set up the sensor in analog zero to be read (int sensorValue = analogRead (A0);). From here, we told the Arduino to give us feedback on what values were being read by the photocell, and to spit that information back out to the computer (Serial.println(sensorValue);). There is a minor delay so the information doesn't start scrolling by too fast.

As you can see, the general range that our photocell is picking up is between 280-302, so we will need to keep those values in mind when we do the next set of code for the later part of the project.

Step 7: Re-wiring for the LED.

To simplify this part of the process, I went ahead and took all the wires out, since we will be sending electricity through the light. We start by putting a wire from the photocell to the positive column of our BREAD board. Then, we line up and place our light a little ways away from the photocell to make sure nothing is too close to cause a short.

(NOTE: you don't have to put your light as far away as I did. I chose to do this so that I could make the pictures I used as clear as possible).

One important note: keep in mind which end of your LED is the longer end, since we will be putting a resistor in line with that end specifically.

Step 8: Finishing Wiring the Photocell

Similar to previous steps, we want to put in a wire from between the resistor and the photocell, connected to our analog A0. We do this so we can take the input given off by the cell, and tell the Arduino what to do with our LED. We also connect our wire for the voltage, and one for the ground as well.

Step 9: Wiring the LED

The last step of wiring we need to do is get our LED light set up. We will add our 220 Ohm resistor here, lining it up so that the resistor is lined up with the long end of the LED light. We then add a wire going from the positive terminal column to the same row as the short end of our LED, and a wire going from the other end of the resistor to the digital output 13 on our Arduino board.

Step 10: Night Light Code.

Above is the code used to do the Arduino night-light.

In the setup, we see that there is a single input and a single output provided. The input is provided by A0, which reads the amount of light being captured by the photocell. This information is then provided to the Arduino. In the digital output slot 13, we have our LED ready to provide power if the photocell tells the Arduino to turn the light on.

In the loop section, we are again telling Arduino to read off the information coming in. This time, instead of simply having Arduino tell us what the photocell is sensing, we are telling it with a conditional statement that if the photocell gives off a value greater than 320, to turn the light on our BREAD board on. If it's below that range, then it can stay off.

Step 11: Live Test.

This is the final result once the board is all hooked up!