This is an old revision of the document!
Unlike the other diodes, the light-emitting diode, also called LED, is a special type that emits light. LED has a completely different body, which is made of transparent plastic that protects the diode and lets it emit light (figure 1). Like the other diodes, LED conducts the current in only one way, so connecting it to the scheme is essential. There are two safe ways to determine the direction of the diode:
The LED is one of the most efficient light sources. Unlike incandescent light bulbs, LED transforms most of the power into light, not warmth; it is more durable, works for a more extended period and can be manufactured in a smaller size.
The semiconductor material determines the LED colour. Diodes are usually made from silicon, and LEDs are made from elements like gallium phosphate, silicon carbide and others. Because the semiconductors used are different, the voltage needed for the LED to shine is also different.
When the LED is connected to the voltage and turned on, a huge current starts to flow through it, and it can damage the diode. That is why all LEDs have to be connected in series with a current-limiting resistor (figure 2).
Current limiting resistors resistance is determined by three parameters:
To calculate the resistance needed for a diode, this is what you have to do.
An example of the blinking LED code:
int ledPin = 8;//Defining the pin of the LED void setup() { pinMode(ledPin,OUTPUT); //The LED pin is set to output } void loop() { //Set pin output signal to HIGH – LED is working digitalWrite(ledPin,HIGH); //Belay of 1000 ms delay(1000); //Set pin output signal to LOW – LED is not working digitalWrite(ledPin,LOW); //Delay of 1000 ms delay(1000); }
LED's brightness can be controlled easily with a PWM signal.
There exist LEDs with more than one light-emitting chip in one enclosure. They are made as two-coloured or RGB elements with coloured controlled separately. There are two internal configurations of such elements:
Digital LED does not have anode or cathode connections available externally. They have power supply pins and two pins for data transmission, one for input and a second for output. The input accepts the digital signal from the microcontroller to set the brightness of all three internal LEDs. Output connects the input of another LED to form a series of LEDs. Digital LEDS are available as single elements but also as strips, rings or matrices that a microcontroller with one pin can control. Every LED can shine in different colours, creating interesting visual effects. An example of a popular digital LED is WS2812. A special protocol is used to transmit data. One LED requires 24 bits (1 byte for red, 1 for green, and 1 for blue) to set the colour. After receiving its data, the LED resends any further byte to the following LEDs in the chain.
There are software libraries for Arduino and other platforms available to ease handling of the digital LEDs, including advanced visual effects for stripes, matrices and other shapes. Sample 8 LED WS2812 stripe is present in the figure 5 and its connection to the MCU in 6.
The example code that uses the popular Adafruir NeoPixel library:
#include <Adafruit_NeoPixel.h> #define PIN 34 // Define the number of the pin connected to the digital LED data input #define NUMPIXELS 1 // Define the number of LEDs in the strip Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800); void setup() { pixels.begin(); // Initialize NeoPixel library } void loop() { // Set the color of the NeoPixel LED setColor(255, 0, 0); // Red color (R, G, B) // Optional: Delay to make the color change visible (in milliseconds) delay(1000); } void setColor(uint8_t red, uint8_t green, uint8_t blue) { for (int i = 0; i < pixels.numPixels(); i++) { pixels.setPixelColor(i, pixels.Color(red, green, blue)); } pixels.show(); }
Using a display is a quick way to get feedback information from the device. There are many display technologies. For IoT solutions, low-power, easy-to-use displays are used:
7-segment LED display The seven-segment LED display is built with seven LEDs forming the shape, making it possible to display symbols similar to digits and even some letters. Usually, the eighth LED is added as the decimal point. 7-segment displays can have similar internal connections as RGB LEDs, common anode or common cathode. If there is more than one digit in the element, all the same segments are also connected together. Such displays need special controllers or the software part that displays separate digits in a sequence one by one. To avoid unnecessary blinking or differences in the brightness of digits, software for sequential displays is written using timers and interrupts. As for the RGB LEDs, 7-segment displays need a separate resistor for every segment. Sample 2-digit 7-segment module is present in the figure 7.
LED matrix display LED matrix displays offer the possibility of displaying not only digits and letters but also some pictograms and symbols. The most popular versions have 8 rows and 8 columns (figure 8), or 7 rows and 5 columns, but it is possible to find other configurations. As for the 7-segment displays, there are common anode and common cathode configurations. For a common anode, all anodes in one row and all cathodes in one column are connected together. For a common cathode, all cathodes in one row and all anodes in one column are connected together. Modern LED matrix displays have built-in controllers or are made with digital RGB LEDs, making it possible to display pictures and even videos.
Liquid-Crystal Display (LCD)
Monochrome LCD uses modulating properties of liquid crystal to block the passing-through light. Thus, when a voltage is applied to a pixel, it is dark. A display consists of layers of electrodes, polarising filters, liquid crystals and a reflector or back-light. Liquid crystals do not emit light directly but through reflection or backlight. Because of this reason, they are more energy efficient. Small, monochrome LCDs are widely used in devices to show a little numerical or textual information like temperature, time, device status, etc. The most popular LCD device is an alphanumerical 2×16 characters display based on the HD44780 controller (figure 9).
There also exist graphic monochrome and colour TFT displays that use LCD technology. LCD modules commonly come with an onboard control circuit and are controlled through parallel or serial interfaces. Sample circuit for 2×16 display is present in figure 10.
The example code:
#include <LiquidCrystal.h> //include LCD library //Define LCD pins const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2; //Create an LCD object with predefined pins LiquidCrystal lcd(rs, en, d4, d5, d6, d7); void setup() { lcd.begin(16, 2); //Set up the LCD's number of columns and rows lcd.print("hello, world!"); //Print a message to the LCD } void loop() { //Set the cursor to column 0, line 1 – line 1 is the second row //Since counting begins with 0 lcd.setCursor(0, 1); //Print the number of seconds since the reset lcd.print(millis() / 1000); }
Organic Light-Emitting Diode Display (OLED)
OLED display uses electroluminescent materials that emit light when the current passes through these materials. The display consists of two electrodes and a layer of an organic compound. OLED displays are thinner than LCDs, have higher contrast, and can be more energy efficient depending on usage (figure 11). OLED displays are commonly used in mobile devices like smartwatches and cell phones, and they are replacing LCDs in other devices. OLED displays come as monochrome or RGB colour devices. Small OLED display modules usually have an onboard control circuit that uses digital interfaces like I2C (figure 12) or SPI.
//Add libraries to ensure the functioning of OLED #include <Wire.h> #include <Adafruit_GFX.h> #include <Adafruit_SSD1306.h> #define OLED_RESET 4 Adafruit_SSD1306 display(OLED_RESET); void setup() { //Setting up initial OLED parameters display.begin(SSD1306_SWITCHCAPVCC, 0x3C, false); display.setTextSize(1); //Size of the text display.setTextColor(WHITE); //Colour of the text – white void loop() { //Print out on display output sensor values display.setCursor(0, 0); display.clearDisplay(); display.print("Test of the OLED"); //Print out the text on the OLED display.display(); delay(100); display.clearDisplay(); }
Electronic Ink Display (E-Ink)
E-ink display uses charged particles to create a paper-like effect. The display comprises transparent microcapsules filled with oppositely charged white and black particles between electrodes. Charged particles change their location depending on the orientation of the electric field; thus, individual pixels can be either black or white (figure 13). The image does not need power to persist on the screen; power is used only when the image is changed. Thus, the e-ink display is very energy efficient. It has a high contrast and viewing angle but a low refresh rate. E-ink displays are commonly used in e-readers, smartwatches, outdoor signs, and electronic shelf labels. The majority of the e-Ink displays are controlled with an SPI interface. Sample connection is present in figure 14.
#include <SmartEink.h> #include <SPI.h> E_ink Eink; void setup() { //BS LOW for 4 line SPI pinMode(8,OUTPUT); digitalWrite(8, LOW); Eink.InitEink(); Eink.ClearScreen();//Clear the screen Eink.EinkP8x16Str(14,8,"IoT e-ink example"); Eink.EinkP8x16Str(10,8,"IoT-open.eu"); Eink.EinkP8x16Str(6,8,"0123456789"); Eink.EinkP8x16Str(2,8,"9876543210"); Eink.RefreshScreen(); } void loop() { }
[pczekalski]Add paper colourfully technologies