Maker.io main logo

4Duino LED Brightness Control

2016-08-15 | By 4D Makers

License: Attribution Arduino

 

 

INTRODUCTION

In this project, we will learn how to control the brightness of LED via an I/O port (with PWM output capability) and a touch display slider. The 4Duino resistive touch display is used as a means for a graphical interface to control the intensity of the LED. Since the 4Duino itself has an LED on pin D13 with PWM output capability, you may use the LED to conduct this project for convenience.

 Square Wave Duty Cycle (PWM)

A LED (light emitting diode) works on the basic principle that when potential difference is applied across the anode and cathode, light is emitted. The higher the potential difference, the brighter the LED shines, therefore PWM (pulse width modulation) allows us to control how much potential difference and therefore the brightness of the LED. A PWM signal is an analog signal emulated by using digital control as a means to create a square wave, a signal switched between on and off.

LEDs being diodes have polarity and will only work if current flows from the anode to the cathode, therefore positive must always be connected to the anode and ground to the cathode. The longer lead of the LED is the anode whilst the shorter lead is the cathode. A resistor is typically placed before the anode in order to lower the current flowing through the led. This will extend the lifespan of the LED and dim the brightness to a level that is more comfortable to look at.

Note: If you end up clipping the leads, the anode lead can be found by looking inside the led and examining the metal contacts. The larger contact is the cathode, and the side of the cathode will be flat on the outside.

Light Emitting Diodes

 

HOW IT WORKS

How it Works

 

COMPONENTS

If not using onboard D13 LED you will require:

  • LED
  • 220Ω Resistor (Used to avoid burning out LED. 5V supplied from the I/O port is too much voltage across an LED)
  • Jumper cables
  • Micro USB cable

 

IMPLEMENTATION

Step 1: Build

Build the circuit as shown in the following diagram and schematic.

Fritzing Board and Schematic Diagrams

 

Step 2: Program

Workshop 4 – 4Duino Basic Graphics environment is used to program this project. (The same could be implemented in the latest Arduino IDE)

This project requires the Arduino IDE to be installed as Workshop calls the Arduino IDE for compiling the Arduino sketches. The Arduino IDE however is not required to be opened or modified to program the 4Duino.

Project File

Open this file using Workshop 4.

Step 3: Comms Port

Connect the 4Duino to the PC using µUSB cable. Then navigate to the Comms tab and select the Comms port to which the 4Duino connected.

Selecting the correct COM port

 

Step 4: Compile and Upload

Finally, go back to “Home” tab and now click on the “Comp’nLoad” button.

Compile and Upload

 

DEMONSTRATION

Now using the touch slider on the 4Duino Display, you can control the brightness of the LED. The brightness of the LED increases as the slider is moved to the right. You can notice in addition, the value of Level increases with the increasing brightness of the LED.

Demonstration

 

4DUINO CODE – FLOW CHART

Flow Chart

 

TechForum

Have questions or comments? Continue the conversation on TechForum, DigiKey's online community and technical resource.

Visit TechForum