Introduction: 4Duino LED Control Using Touch Button
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.
Step 1: How It Works
User provides a touch input by pressing the button on the display. Picaso (graphical controller) which drives the display, receives and processes this touch input. Picaso controller communicates the information to ATMega32U4 via Hardware Serial (D0, D1)
As per the program, ATMega32U4 sets the D13 pin of the 4Duino HIGH and turns the LED on. In addition, ATMega32U4 requests Picaso to update the LED State on the 4Duino Display
Step 2: Build
- Micro USB cable
- 220 Ohm Resistor
- and Breadboard (optional)
4Duino has an inbuilt LED connected to the I/O pin D13. Circuit building is not required at this stage.
But if you want to use an LED, connect it to D13 pin of 4Duino with 220 Ohm resistor on its ground.
Step 3: 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.
- Download the project here.
- Open this file using 4D Workshop.
- 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.
- Finally, go back to “Home” tab and now click on the “Comp’nLoad” button.
Step 4: Demonstration
The state of the LED on D13 can now be controlled via the button widget on the display.
You can also extend this project by using the GPIO pins of 4Duino and modifying the program.
For more creative stuff visit 4Duino Projects.
We have a be nice policy.
Please be positive and constructive.