Week 9

Home Assignment

Output Devices

#_Tasks_:)

1. Group assignment:
measure the power consumption of an output device.
2. Individual assignment:
add an output device to a microcontroller board you've designed, and program it to do something.

#_What are Output Devices?

An Output Device is any piece of computer hardware that converts information or data into a human-perceptible form or, historically, into a physical machine-readable form for use with other non-computerized equipment. It can be text, graphics, tactile, audio, or video. Examples include monitors, printers, speakers, headphones, projectors, GPS devices, optical mark readers, and braille readers.

1. RGB LED:

LEDs is a output device which offer high energy efficiency, converting a larger portion of electrical energy into light and making them the preferred choice for various lighting and display applications.
The RGB LED can produce any color,
An RGB LED is a combination of 3 LEDs in just one package:

We can produce almost any color by combining those three colors. An RGB LED is shown in the following Image:

Image

#_Programming the RGB LED... :)

Code:

#define RED_LED_PIN 7
#define GREEN_LED_PIN 8
#define BLUE_LED_PIN 9

void setup() {
// Configure LED pins as outputs
pinMode(RED_LED_PIN, OUTPUT);
pinMode(GREEN_LED_PIN, OUTPUT);
pinMode(BLUE_LED_PIN, OUTPUT);

// Set common anode pin high for common anode LED
digitalWrite(RED_LED_PIN, HIGH);
}

void loop() {
// Set different colors (LED on = LOW, LED off = HIGH for common anode)
digitalWrite(GREEN_LED_PIN, LOW); // Turn green on
digitalWrite(RED_LED_PIN, LOW); // Turn red on
digitalWrite(BLUE_LED_PIN, HIGH); // Turn blue off
delay(1000);

digitalWrite(GREEN_LED_PIN, HIGH); // Turn green off
digitalWrite(RED_LED_PIN, HIGH); // Turn red off
digitalWrite(BLUE_LED_PIN, LOW); // Turn blue on
delay(1000);
}

#_Output... :)

2. LCD:

A liquid-crystal display (LCD) is a flat-panel display which uses the liquid crystals for giving the output. A 16x2 LCD display is very basic module and is very commonly used in various devices and circuits.
How LCDs works?
A display is made up of millions of pixels. The quality of a display commonly refers to the number of pixels; for example, a 4K display is made up of 3840 x2160 or 4096x2160 pixels. A pixel is made up of three subpixels; a red, blue and green—commonly called RGB. When the subpixels in a pixel change color combinations, a different color can be produced. With all the pixels on a display working together, the display can make millions of different colors. When the pixels are rapidly switched on and off, a picture is created.

The way a pixel is controlled is different in each type of display; CRT, LED, LCD and newer types of displays all control pixels differently. In short, LCDs are lit by a backlight, and pixels are switched on and off electronically while using liquid crystals to rotate polarized light. A polarizing glass filter is placed in front and behind all the pixels, the front filter is placed at 90 degrees. In between both filters are the liquid crystals, which can be electronically switched on and off.

LCDs are made with either a passive matrix or an active matrix display grid. The active matrix LCD is also known as a thin film transistor (TFT) display. The passive matrix LCD has a grid of conductors with pixels located at each intersection in the grid. A current is sent across two conductors on the grid to control the light for any pixel. An active matrix has a transistor located at each pixel intersection, requiring less current to control the luminance of a pixel. For this reason, the current in an active matrix display can be switched on and off more frequently, improving the screen refresh time.

Some passive matrix LCD's have dual scanning, meaning that they scan the grid twice with current in the same time that it took for one scan in the original technology. However, active matrix is still a superior technology out of the two.

Image

Types of LCDs include:
1. Twisted Nematic (TN)- which are inexpensive while having high response times. However, TN displays have low contrast ratios, viewing angles and color contrasts.
2. In Panel Switching displays (IPS Panels)- which boast much better contrast ratios, viewing angles and color contrast when compared to TN LCDs.
3. Vertical Alignment Panels (VA Panels)- which are seen as a medium quality between TN and IPS displays.
4. Advanced Fringe Field Switching (AFFS)- which is a top performer compared IPS displays in color reproduction range.

#_Programming the I2C LCD... :)

1. Connections of I2C LCD Display to an Xiao ESP32 C3
ESP32C3 --> I2C LCD
SDA --> SDA
SCL --> SCL
3.3V --> 3.3V
GND --> GND
2. Adjusting The LCD Contrast
On the I2C module you will find a potentiometer that you can rotate with a small screwdriver to Adjust the contrast of the display.
3.Library Installation
To drive an I2C LCD you must first install a library called LiquidCrystal_I2C
To install the library go to Sketch --> Include Libraries --> Manage Libraries. Wait for Library Manager to download the library index and update the list of installed libraries.
Filter your search by typing ‘liquidcrystal‘. There should be some entries. Look for the LiquidCrystal I2C library by Marco Schwartz. Click on that entry, and then select Install.
4. Determining the I2C Address
The I2C address of your LCD depends on the manufacturer, as mentioned earlier. If your LCD has a Texas Instruments’ PCF8574 chip, its default I2C address is 0x27Hex. If your LCD has NXP Semiconductors’ PCF8574 chip, its default I2C address is 0x3FHex.
So your LCD probably has I2C address 0x27Hex or 0x3FHex. However it is recommended that you find out the actual I2C address of the LCD before using it. Luckily there’s an easy way to do this. Below is a simple I2C scanner sketch that scans your I2C bus and returns the address of each I2C device it finds.


Code:

#include

LiquidCrystal_I2C lcd(0x3F,16,2); // set the LCD address to 0x3F for a 16 chars and 2 line display

void setup() {
lcd.init();
lcd.clear();
lcd.backlight(); // Make sure backlight is on

// Print a message on both lines of the LCD.
lcd.setCursor(2,0); //Set cursor to character 2 on line 0
lcd.print("SANJIVANI FAB LAB");
lcd.setCursor(2,1); //Move cursor to character 2 on line 1
lcd.print("AKASH MHAIS");
}

void loop() {
}

After uploading the code, open the serial monitor at a baud rate of 115200 and press the EN button on the ESP32. You will see the I2C address of your I2C LCD display.
Tutorial reference --> Last Minute Engineers


3. Buzzer:

A buzzer or beeper which may be mechanical, electromechanical, or piezoelectric (piezo for short). it is an electronic signaling device that makes a buzzing sound.

Image

1. Electromechanical:
The electric buzzer was invented in 1831 by Joseph Henry. They were mainly used in early doorbells until they were phased out in the early 1930s in favor of musical chimes, which had a softer tone.
Early devices were based on an electromechanical system identical to an electric bell without the metal gong. Similarly, a relay may be connected to interrupt its own actuating current, causing the contacts to buzz (the contacts buzz at line frequency if powered by alternating current) Often these units were anchored to a wall or ceiling to use it as a sounding board. The word "buzzer" comes from the rasping noise that electromechanical buzzers made.
2. Piezoelectric:
Piezoelectric buzzers, or piezo buzzers, as they are sometimes called, were invented by Japanese manufacturers and fitted into a wide array of products during the 1970s to 1980s. This advancement mainly came about because of cooperative efforts by Japanese manufacturing companies. In 1951, they established the Barium Titanate Application Research Committee, which allowed the companies to be "competitively cooperative" and bring about several piezoelectric innovations and inventions.
A piezoelectric element may be driven by an oscillating electronic circuit or other audio signal source, driven with a piezoelectric audio amplifier. Sounds commonly used to indicate that a button has been pressed are a click, a ring or a beep. Interior of a readymade loudspeaker, showing a piezoelectric-disk-beeper (With 3 electrodes ... including 1 feedback-electrode ( the central, small electrode joined with red wire in this photo), and an oscillator to self-drive the buzzer. A piezoelectric buzzer/beeper also depends on acoustic cavity resonance or Helmholtz resonance to produce an audible beep.

#_Programming the Buzzer... :)

#define buzzerPin 0 // (any digital pin)

void setup() {
// Configure the buzzer pin as output
pinMode(buzzerPin, OUTPUT);
}

void loop() {
// Play a simple tone
tone(buzzerPin, 1000); // 1 kHz Frequency
delay(250); // 250 milliseconds Duration

// play a silent period
noTone(buzzerPin);
delay(250); // 250 milliseconds Duration of silence
}

#_PCB_Designing_in_Eagle_:)

Image

I will going to use a 2 pin connector, 4 pin connector, push button, LED and Resistor, these are the Schematic symbol of all the components.

Image

This is the Schematic of my output devices board

Image

I used the Connectors from Sparkfun Library but they are very small so i just changed the footprints by editing the library. for that select the symbol --> right click on it --> navigate to open device.

Image

Select the footprint which we have to edit.

Image

By right clicking on that select edit footprint option.

Image

I changed the footprints settings according to the connectors that I have available in our fab lab.

Image

I have designed the board by setting the trace width 16 mils.

Image

after the design of all the traces i navigated to the dimension layer option.

Image

I drawn the outline for the board.

Image

Then I go to layers and selected the Hide Layers option, for this pcb only top layer and the dimension layer is required.

Image

I selected the Top layer for converting it into png format.

Image

For converting it go to File --> Export --> Image.

Image

the Export Image window will popup, Select Monochrome option and 1000 pixel resolution for the fine quality.

Image

For the outline again select the dimension layer and hide remaining all layers.

Image

For converting it into .png format, go to File --> Export --> Image.

Image

the Export Image window will popup, Select Monochrome option and 1000 pixel resolution for the fine quality.

Image

This is the output of the PCB designing in Eagle software.

Image

I mill this on PCB milling machine and then i soldered it



FAB ACADEMY - Akash Mhais 😎