In this project, we will learn how to turn an LED ON or OFF via the 4Duino I/O port (D13) and a button widget from 4D Workshops. The 4Duino’s resistive touch display is used as a means for a graphical interface to control state of the LED. For convenience, we will use the LED on pin D13 of the 4Duino to conduct this project. An 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. 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. The plastic casing of the LED can be used to determine polarity on the LED as well – the side of the cathode will have a flat edge.

LED-control

HOW IT WORKS

how-it-works-pr1

COMPONENTS

This projects utilizes the internal circuitry of the 4Duino, hence no external components is required for this project. However, you will require a Micro USB cable to program the 4Duino.

IMPLEMENTATION

Step 1: Build

4Duino has an inbuilt LED connected to the I/O pin D13. Circuit building is not required at this stage.

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.

Led-control-3

Open this file using 4D Workshop.

Note: Download the project here.

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.

Led-control-4

Step 4: Compile and Upload

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

Led-control-5

DEMONSTRATION

The state of the LED on D13 can now be controlled via the button widget on the display.

Project-1b-1 Project-1b-2