Arduino Projects with Light (Using Sparkfun RedBoard)

Updated 18 May 2018

Now that your RedBoard is set up on its baseplate and the Arduino IDE is installed on your computer, we can begin our first Arduino-based Project Set! The First Project Set explores light and the type of electrical component we will be using is a Light Emitting Diode (more commonly known as an LED). We have compiled a tutorial All About LEDs if you're interested in learning more about their design, use, and variations. 


A Brief LED Introduction

Simply put, an LED is a ‘one-way’ electronic component which converts electrical energy into visible light. The uni-directional nature of the LED is important as an incorrectly connected diode could result in the component breaking. The long ‘leg’ of a normal LED should be connected to the higher potential with the shorter end going to a lower electrical potential. The included RGB LED has a different connection convention which will be explored later in this Project Set.

This brings us to the next important part of an LED which is limiting current. Although an LED is designed to have current flow in a certain direction, if that current is too high (typically > 20mA) then the LED can break! To avoid this, an LED should always be connected in series with a current limiting resistor (330 Ohms is usually a large enough size). 

sparkfun-included-leds
Some of the included LED's in the Sparkfun Inventors Kit (Ver 4.0)

Project 1 - Circuit 1A

This circuit will be our “Hello World” example in which we will get an onboard and a circuit-connected LED to flash on and off every 4 seconds. It will cover the use of the ‘pinMode()’, ‘digitalWrite()’ and ‘delay()’ functions and we will also explain the need for the void ‘setup()’ and ‘loop()’ functions.

Important notes:

  • Disconnect the RedBoard from the computer before connecting anything to the Power Bus
  • Make sure that the LED is connected the correct way (polarity-wise and with the current limiting resistor)
  • Ensure +5V isn’t connected straight to GND through the power rail or otherwise


Project 1 - Circuit 1B

Now that our first RedBoard Project is complete we will up the ante by introducing an analog element into our circuit. This will be done using a component called a Potentiometer in hand with one of the six Analog Pins provided on the RedBoard. A Potentiometer is a variable resistor (the one in your Sparkfun Inventors Kit looks like a blue dial). It uses an internal voltage divider to give an analog reading at the center pin which is then converted to a digital value from 0-1023 at the RedBoard. The function ‘analogRead()’ will be used in this circuit set up to read the value from the A0 pin along with our first variable which will be used to store the output measured there. We will also use the serial monitor to read the input received at A0.

This circuit is of a similar build to the first, so you can leave the LED where it is. The only thing that we’re modifying is the inclusion of potentiometer and the use of power rails.

Important notes:

  • Disconnect the RedBoard from the computer before connecting anything to the Power Bus
  • Make sure that the LED is connected the correct way (polarity-wise and with the current limiting resistor)
  • Ensure +5V isn’t connected straight to GND through the power rail or potentiometer


Project 1 - Circuit 1C

Circuit 1C will introduce another analog component into the mix which is known as a photoresistor. A photoresistor is a variable resistor that changes its resistance in accordance with the amount of visible light that shines upon it. This property allows for light-sensitive projects to be created where a switching event will happen at a given ambient brightness (think nightlight or switch that activates at daytime). Another ‘int’ variable will be used to store the voltage divider value and a constant will be used to specify the ambient light threshold.

Important notes:

  • Disconnect the RedBoard from the computer before connecting anything to the Power Bus
  • Make sure that the LED is connected the correct way (polarity-wise and with the current limiting resistor)
  • Ensure +5V isn’t connected straight to GND through the power rail or otherwise


Project 1 - Circuit 1D

The final Circuit to build in the light-projects set combines everything learned in the first 3 circuits and more with the introduction of an RGB LED. As mentioned previously, the RGB LED has a different connection convention due to its four legs and, hence, 3 inputs (Red, Green, Blue). Different input combinations to the LED’s pins will allow for a wide spectrum of colours to be produced; this will be the focus of this circuit.

sparkfun-rgb-led-connection-convention

The Sparkfun Inventors Kit code that was mentioned in the IDE setup video would be a useful tool to have for this circuit as the code is quite long if we want the circuit to operate the way described in the guide.

Important notes:

  • Disconnect the RedBoard from the computer before connecting anything to the Power Bus
  • Make sure that the RGB LED is connected the correct way (shown above)
  • Ensure +5V isn’t connected straight to GND through the power rail or potentiometer

Congratulations! You have now finished your first Project Set and your first 4 Circuits! The next Project Set explores the use of Sound using buzzers. If you've gone too far ahead and what to see how to set up the RedBoard, we have a Getting Started tutorial you should check out. 

Have a question? Ask the Author of this guide today!

Please enter minimum 20 characters

Your comment will be posted (automatically) on our Support Forum which is publicly accessible. Don't enter private information, such as your phone number.

Expect a quick reply during business hours, many of us check-in over the weekend as well.

Comments


Loading...
Feedback

Please continue if you would like to leave feedback for any of these topics:

  • Website features/issues
  • Content errors/improvements
  • Missing products/categories
  • Product assignments to categories
  • Search results relevance

For all other inquiries (orders status, stock levels, etc), please contact our support team for quick assistance.

Note: click continue and a draft email will be opened to edit. If you don't have an email client on your device, then send a message via the chat icon on the bottom left of our website.

Makers love reviews as much as you do, please follow this link to review the products you have purchased.