السبت، 12 ديسمبر 2015

PIC Microcontroller Primer – Tutorial #1

pic microcontroller tutorial Welcome to the starting line of the PIC Microcontroller Primer. Microchip manufacture a series of microcontrollers called PIC, and this tutorial series will take you from the basic structure of PIC µCs right through to the programming methods and techniques.
Note that there are many different PIC µC packages are now available, from some basic low memory types to ones that have analogue to digital converters (ADC) and even pulse width modulator (PWM) blocks built in. At first, I am going to focus on the emblematic PIC12F675 µC. Once you have learnt how to program one type of PIC µC, learning the rest is sweet and simple!

PIC 12F675 microcontroller
PIC 12F675 is an 8-Pin, Flash-Based 8-Bit, PIC ® Mid-Range CMOS µC, comes in 8-pin PDIP, SOIC, MLF-S and DFN packages. One advantage of PIC12F675 when compared to its predecessor PIC 12F629 is that 12F675 has an inbuilt 10-bit ADC. In short, the feature-packed 12F675 has 1024 words of program memory, 64 Bytes of RAM and 128 Bytes of EEPROM, an internal oscillator, timers, an ADC and a comparator. Since this tutorial part contains basic device specific information for the PIC12F675, additional information may be collected from the datasheet published by Microchip.
PIC 12F675 Mini Development Board
As a part of learning, it is recommended to build your own PIC12F675 mini development board. The circuit shown here is easy enough to make a development board yourself. For hardware all we need is a standard piece of perforated prototyping board, ic socket, headers with a 0.1 inch (2.54 mm) pitch, and a handful of discrete components in addition to the fixed voltage regulator chip and the PIC12F675 microcontroller. The components of the development board can be mounted on the top side of the prototyping board (as usual) and soldered on its underside. Then attach the headers to the prototyping board with solder joints on its underside. Remember to leave a little gap between the underside of the prototyping board and the plastic carrier of the headers to allow for soldering there later. Ordinary wire can be used to connect between the components and the header pins. The development board can be powered from any 9-12 V standard dc power supply source.
headers on the prototyping board
(headers on the prototyping board – an example)
Here is the circuit diagram of the mini development board. The ICSP header in the board allows you to program the PIC 12F675 microcontroller using an ICSP programmer (will discuss later).
pic development board circuit
PIC USB Programmer
Microchip’s PICKit2 is a USB based ICSP (In Circuit Serial Programming) programmer. This programmer is preferred here because it is much more comfortable, reliable and powerful than any other programmer we can find all over the internet world.
Well, next is a simple programming tutorial on the PIC 12F675 microcontroller which shows you how to program and use it as a simple LED flasher.

PIC Microcontroller Primer – Tutorial #2

PIC2 - 1
As promised, this part starts with a simple programming tutorial on the PIC12F675 microcontroller which shows you how to program and use it as a simple LED flasher. It’s assumed that you have successfully constructed your own PIC mini development board, and you have a PIC usb programmer (PIC Kit 2) in your hand. Well, then get ready to prepare your little hardware for this minor experiment, as instructed below.

Hardware Wiring
As you can see the hardware is very simple and only requires a 5mm Red LED and a 1K resistor, in addition to the PIC mini development board. The LED is connected between GPIO 2 (pin 5) of the PIC 12F675 microcontroller and the ground (0V) rail through the 1K current limiting resistor.
PIC hardware wiring
Software Code
For the sake of simplicity, a ‘ready-to-use’ hex code is used here. Just download the hex file (Hello_LED.Hex) from the indicated link, and burn it into the PIC12F675 microcontroller with the help of your PIC Kit 2 programmer. Note that, this is only a simple approach to test the PIC12F675 microcontroller of your mini development board. From the next part, you can learn how to program PIC microcontrollers using your own codes!
PIC Kit 2 Microcontroller Programmer Guide
Inorder to get the best from your PIC Kit 2 Microcontroller Programmer, it is recommended to download the PIC Kit 2 user guide from http://www.pic16.com/soft/PICkit2_USER_GUIDE.pdf This user’s guide describes how to use PIC Kit 2 Microcontroller Programmer. Other useful notes are also included in this detailed official documentation.
The PIC KIt 2 Microcontroller Programmer can program PIC microcontrollers that are installed in an application circuit using In-Circuit Serial Programming (ICSP). In-Circuit Serial Programming (ICSP) requires five signals:
  • VPP/MCLR – Programming Voltage (when applied, the device goes into programming mode)
  • PGC or ICSPCLK – Programming Clock (a unidirectional synchronous serial clock line from the programmer to the target)
  • PGD or ICSPDAT – Programming Data (a bidirectional synchronous serial data line)
  • VDD – Power Supply (positive voltage)
  • VSS – Power Supply (ground reference)
When you are familiar with your PIC Kit 2 microcontroller programmer, interconnect the mini development board (MDB) with PIC Kit 2 as shown below. Since, you can safely power the mini development board (at this time) by the PICkit™ 2 Microcontroller Programmer itself, remember to switch off the mini development board’s power supply during ICSP programming!
pickit 2 connector
MDB and PIC Kit 2 pin connection
After this ICSP wiring, connect the PIC Kit 2 programmer to your PC and open the PICKit2 Software. After Opening the PICKit2 Programmer Tool, click Erase, and after Erasing Import the downloaded Hex file from the stored location (File → Import).
pic programmer tool
After Importing the Hex File, write the program to PIC by clicking the Write button. After programming, you may verify the program in the PIC Microcontroller with the Hex file using the Verify button. This can used to check whether the program in the microcontroller is corrupted or not. Now remove the ICSP wiring, and power the mini development board from its own power supply. If everything is okay, you can see that the LED is flashing continuously with about 4Hz frequency at 50% duty cycle.
Yes, now you are sure that your PIC12F675 (in your MDB) is functioning well, and your PIC Kit 2 microcontroller programmer can successfully burn hex files from your computer to the microcontroller chip. Certainly, not a bad evening!
 

Holtek HT12E encoder in high-density ASK R-C applications

The high-density ASK (amplitude shift keying) environment is one in which there are so many transmissions occurring at a given frequency that they occasionally collide and thus fail to get properly decoded by the targeted receivers. There are a number of potential solutions, but in this discussion we are concentrating on limiting the transmitter On-period. This is accomplished by operating the encoder IC at the maximum data rate and by limiting the transmitter On-time via a monostable multivibrator. Obviously, this is not appropriate for critical applications, but provides an inexpensive solution for many non-critical applications. For a complete mini-system, the HT12E encoder must be matched with a HT12D decoder.


Schematic
transmitter schematic
Datasheet link (http://www.holtek.com.tw/pdf/consumer/2_12ev120.pdf)
Key contact de-bounce multivibrator
The most significant problem occurs when the operator keys the encoder for an extended period of time. This essentially jams the frequency so that no other transmissions can be received. To prevent this from occurring, a monostable multivibrator keys the encoder for about 20mS. This limits the transmission to the minimum 4word data burst. To prevent the transmitter from being keyed by rapidly pressing the key button, another section of the monostable multivibrator prevents successive keying until a 1.2sec timeout period has elapsed.
The 74HC221 non-retriggerable monostable multivibrator is ideal for this function. Do not confuse this device with the 74HC123 retriggerable monostable multivibrator that has the same pin-out.
Battery life
Battery life should be excellent as both the monostable and encoder are CMOS –neither draw measurable current when at rest. Limiting the transmission time also reduces battery load. As a result, the battery may never need replacement. The way the 74HC221 monostable works is that there is no voltage across the timing resistors when the device is at rest –without voltage, they cannot add load. Note that not all monostables work this way –some have significant standby current.
Data format /protocol
The Holtek device has a unique, non-standard data format and protocol. It is optimized for low cost, minimum component count and functionality. Conversely, the UART (universal asynchronous receiver /transmitter) approach requires a close frequency match. This requires expensive crystal oscillators etc. In the Holtek devices, transmit and receive frequencies are crudely matched –perhaps within about 10%. To make data synchronization reliable, each bit gets individually synchronized via timing from the leading edge of a positive going sync pulse that occurs immediately before each data state period. Data remains reliable up to perhaps 30% transmitter /receiver frequency mismatch. The down side is that this technique halves the data rate, or doubles the transmit period.
Each data word consists of a sync pulse and 12bits of address /control data. This is repeated a total of 3 times so that the data burst consists of (4) identical words. At an oscillator frequency of 5.5kHZ, this requires 45mS. Ideally, this allows for 22 transmissions per second. In a high-density environment, it has a practical limit of perhaps 5 transmissions per second in order to avoid excessive collisions.
Oscillator frequency
The datasheet shows how the frequency is set via changing a resistor between 470K and 2M. The frequency is also a function of battery voltage, but there is sufficient latitude between a fully charged and a discharged battery to maintain satisfactory operation. For this exercise, I set the frequency to 5.5kHZ (max) via a 470K resistor. Battery voltage is 3V.
Other means of increasing the transmitter density
Initial experiments indicate that the oscillator may be bumped up to 22kHZ by reducing the oscillator resistor from 470K to 100K and that the frequency seems to track in a near linear fashion (note that the Holtek 12A device runs at 38kHZ). While this is a nice improvement, it is an out-of-spec condition and not all devices may function. Also, it is unknown at this point if the receiver can be tweaked to follow at this speed. So for now, this is ‘Twilight Zone’ speculation…
A more reliable means to increase transmitter density is to add additional frequencies and to color code units so that the transmitters may be matched with receivers. Since there are three or four standard frequency offerings, this is practical. Another means to marginally reduce environment density is to reduce range via reducing transmit power and /or receiver sensitivity.
My guess is that if a number of the above means are employed, the maximum number of transmissions may easily approach 20transmissions per second.
Replacing the HT12E /HT12D chip set with microcontrollers may increase this by an order of magnitude, but such requires significant programming and testing –not a simple solution.
Oscillographs

Photos

Undocumented words and idioms (for our ESL friends)
Twilight Zone –idiom –a takeoff from Rod Sterling’s popular paranormal TV series of 50years ago


الخميس، 10 ديسمبر 2015

AC Light Dimmer Module with ZC Detector

From time to time I get requests to make some high power switching, so I decided to design a digital dimmer module that could handle a lot of different situations. The original requirements laid down that the design must be of the open type, that is, it must be possible for individual users to develop a program or alter an existing one for controlling an ac load through the dimmer module.

The compact ac light dimmer module with zero-crossing detector described here is ideal for microcontroller-based ac voltage controlling applications and projects. This module contains a triac triggering coupled with zero-crossing signal detection mechanism for programming the intensity of incandescent lamps and/or fan speed controlled through a microcontroller circuitry. Circuit of the module shown here offers improved performance and reliableness using very little power and just a few plain vanilla components.
The AC Light Dimmer Module Circuit
It is clear from the circuit diagram that the key component of the design is a standard triac (TR1). The circuitry which is linked to the microcontroller via the signal input header (H1) drives an optoisolator triac driver (OC1). One set of terminals of this component is connected to the triac, whereas the set of terminals at the otherside is switched via the I/O line of the external microcontroller and an integral current-limiting resistor (R1). Since the triac incorporate a snubber network, the dimmer can be used for controlling inductive loads,too. The next optocoupler (OC2) serves to detect the mains zero-crossing.
Zero-crossing is used for synchronizing the dimmer. The optoisolator is linked directly to the mains supply since a transformer causes an unwanted small phase shift that may induce anomalies in the performance. The synchronizing pulse is buffered by a small signal transistor (T1) and routed to the signal output header (H2).
The circuit can be assembled on a small perfboard, and the work is straight forward as long as the specified components are used. Since several tracks carry the full mains voltage, extreme care is required in the assembly. Always unplug the module from the mains before doing any work or checking some thing after assembly. Also note that to ensure correct operation the module should be connected to a frequency-stable mains supply only. The dimmer module may be used for stage lighting, for controlling domestic lights, for illuminating aquariums, or for mood lighting.
AC Light Dimmer Module Circuit
Since the switching input (SW) and zero‐crossing (ZC) output are available on separate headers (H1 and H2) on the board, this module is still usable without a microcontroller. Further, you can add or remove components based on particular needs. For example, incase no need for inductive load control just omit the snubber (C3-R5). On the other hand, if you want to integrate the module into an existing digital design, just skip the “external” microcontroller idea and use the switching input and zero-crossing output connections directly.
Parts List
Resistors:
  • R1,R4=180R ¼ w, 180R 1w
  • R2,R3=680R ¼ w, 680R 1w
  • R5=39R 2w
  • R6=56K 1w
  • R7=10K ¼ w
  • R8=1M ¼ w
Capacitors:
  • C1=100nF
  • C2=100nF 275V ~
  • C3=10nF 630V~
Semiconductors:
  • OC1=MOC3021
  • OC2=4N35
  • TR1=BT136 mounted on heatsink
  • T1=BC547B
  • D1=1N4001
  • LED1= 3mm Red 10mA
Miscellaneous:
  • H1, H2 =3-pin male headers J1,J2=PCB Screw Terminals…
Application Hint
As you may noticed, the module comprises two independent input and output connections; one pair in the low-voltage side (H1 & H2) and other in the high-voltage side (J1 & J2). You can feed the “dimming control signal” output (SW) from an I/O port of a microcontroller to the input header H1, and the “zerocrossing signal” output (ZC) available from the module (through output header H2) to an I/O port of the same microcontroller. Similarly, connect the utility power at AC-IN connector (J1) and intended control device into AC-OUT connector (J2). An indicator (LED1) is provided onboard to test the triac trigger system. This indicator will be full bright when LOAD is 100% ON state. The triac in the module BT136 supports 4A Max. i.e 920W @ 230VAC. Incase of a higher-current requirement, you can change this triac with a suitable type. The heatsink would still be required for the triac to safely handle higher currents (assuming operation at room temperature).
zc module connections
Note: Network C3-R5 is for snubbing of the triac (TR1), and C2-R3 for snubbing of the coupler (OC1). These components may or may not be necessary depending upon the particular triac used and the load connected.

الأربعاء، 9 ديسمبر 2015

Digital volume control circuit schematic

This is digital volume control circuit that Can be applied to the normal volume of a power amplifier. When press switch S1 adds up the volume and press switch S2 to reduce the volume down.
How it works
IC1 is a 555 CMOS Timer Single IC will be connected in astable flip-flop model as pulse frequency generator up / down to input pin of the counter IC2-74LS193, through push-bottom switch S1 (Up) and S2(Down).
digital-volume-control-circuit-schematic
Changing wide of pulse signal from IC1 may replace R1 with potentiometer.
To begin with, when we press the switch S1 (increase sound) binary output will be add up and when press switch S2 (Reduce sound) the binary output will low down. The maximum counter to count to 15 (All output are logic “1” or “Higher”) and lowest is the counter 0 (All output are logic “0”).
The output ABCD of the counter IC2 will use to control both gate. Which is bipolar analog switch (IC3 and IC4 – CD4066). In either bit output are “High” logic. The resistors connected in series are the resistors R6-R9. In left signal channel and R10-R13 for right signal channel.
In this way, the control output of sound signal to the output of the power amplifier. The switch S3 is used to reset the output of the counter to 0000. For this reason, to make adjustments to the volume of both channels is low.
Parts you will need
Resistors ¼ W +-5%
R1_________________150K
R2_________________330K
R3, R4, R5__________550 ohms
R6, R10____________1K
R7, R11____________2K
R8, R12, R14, R15___4.7K
R9, R13____________8.2K
Capacitors
C1_________________1uF 25V Electrolytic
C2_________________0.1uF Ceramic
Semiconductors
IC1_________________IC-7555 CMOS Timer Single 8-Pin Plastic Dip
IC2_________________IC-74193______Synchronous Up/Down 4-Bit Binary Counter with Dual Clock
IC3, IC4_____________CD4066 Quad Analog Switch/Multiplexer/Demultiplexer
Others
S1, S2, S3 switch normally open pushbutton

الثلاثاء، 8 ديسمبر 2015

Multiple Shift-out Registers on Arduino – part 2



Arduino daisy chain 7 segment leds

In this second article we will see a practical application of the daisy-chained shift registers.

We want to use four 7-Segments LEDs controlled by the Arduino board. As you can imagine, that is impossible without a series of shift-registers as we need 32 output pins. As we can do in many other applications of the daisy-chained shift registers, in this case we don’t need a specific software or library: it is sufficient what we already know about the shift registers.

As in the previous article I wrote that the board is a general purpose tool, this is one of the hundreds possible applications that only need hardware. The only thing we must know is how the 7-segments LED devices work.

The 7-segments LED devices

The general principle behind this kind of devices is the same that makes the common LEDs working. To get a LED lighting we should connect its ground pin to the circuit GND and the positive pin to an output pin on the microcontroller. Everytime the microcontroller pin goes high the LED is powered.

led resistor circuit

It’s important to know that there are two different types of 7-segments LED displays: common cathode and common anode. As shown in the scheme below the common cathode display shares the GND signal while the common anode display shares the VCC signal.

7-segment2

By the point of view of the circuit schematics there are no particular differences and we have adopted common anode devices because of some advantages compared to the opposite common cathode.

Schematics[2]

The only different thing is our sketch; We should consider that with this kind of configuration a certain LED segment will light when the corresponding digital pin of the shift register is set to LOW and vice-versa.

Display-7Seg 11

As the 7-segments display components have eight independent LEDs (seven for the bars and one extra for the point), every segment corresponds to one of the 8 signals/pins of the corresponding shift register so the four display board consumes four shift registers.

Why the choice of the Common Anode Display

The board has a set of connectors showing 33 pins: four sets of eight pins plus the common pin connected to the anodes of the four devices. This 33th pin can be connected to the shift register board – explained in the previous article – that shares the VCC signal on its connectors: simply connect one-to-one the two boards and it will work.

Display-7Seg 9

But what happens when you connect the VCC common anode of the board to one of the free digital pins of the Arduino? Setting the common anode digital pin to HIGH, we power on the entire display board while setting it to LOW the display board will not work. One more suggestion: if we use an Arduino PWM pin as the common anode pin, we can power on/off the display and change its brightness.

What if using Common Cathode Display

If we put in the sockets four 7-segments LED common cathode LCD display devices, we should connect the pin 33 of the board (the common pin) to the Arduino GND signal. At this point, all works fine again, the only difference being that every display LED segment is enabled when the corresponding shift register signal is ON and is disabled when the signal is OFF.

PCB-Botttom

7-segments Display mapping

As every segment is associated to one of the corresponding bits (with an extra eight bit for the separator point) there are 128 different statuses of the devices. With the board and the daisy-chained shift register we can set any of these configurations but the most common are the characters 0-9 and A-F. For more information on how the 7-segments LED displays work, read this almost exhaustive description on wikipedia.

7-segment-map

Sketches suggestions and samples

What now? There are many helpful suggestions to manage the board in your Arduino sketches. The ideal hardware configuration will be the four daisy-chained shift registers described in the first part of this article and the 7-segments board discussed above.

Don’t forget to try using an Arduino digital pin instead of the VCC pin to control the common anode signal of the LEDs.

  1. #include <ShiftOutX.h>
  2. #include <ShiftPinNo.h>
  3.  
  4. // Digital pins connected to 74HC595
  5. int latchPin = 2; // pin 12 on the 74hc595
  6. int dataPin = 3; // pin 14 on the 74hc595
  7. int clockPin = 4; // pin 11 on the 74hc595
  8.  
  9. // Digital pin to enable/disable the display common Anode
  10. int vccControlPin = 7;
  11.  
  12. //shiftOutX(_latchPin, _dataPin, _clockPin, _bitOrder, _NofRegisters);
  13. shiftOutX shiftDisplay(latchPin, dataPin, clockPin, MSBFIRST, 4);
  14.  
  15. void setup() {
  16. // Set the ShiftRegister PINs
  17. pinMode(latchPin, OUTPUT);
  18. pinMode(clockPin, OUTPUT);
  19. pinMode(dataPin, OUTPUT);
  20.  
  21. // Set the common Anode control pin
  22. pinMode(vccControlPin, OUTPUT);
  23. // Disable (power off) the display disabling the common Anode pin
  24. digitalWrite(vccControlPin, LOW);
  25. // Initialize the serial (for testing purposes)
  26. Serial.begin(9600);
  27. // Startup message
  28. Serial.println("/*** Display 7 Segments Test Started ***/");
  29.  
  30. }
  31.  
  32. void loop() {
  33. // Enable the display
  34. digitalWrite(vccControlPin, HIGH);
  35. Serial.println("- Display on");
  36. delay(2000); // wait 2 sec
  37.  
  38. shiftDisplay.allOn();
  39. Serial.println("- shiftDisplay.allOn()");
  40. delay(2000); // wait 2 sec
  41. shiftDisplay.allOff();
  42. Serial.println("- shiftDisplay.allOff()");
  43. delay(2000); // wait 2 sec
  44. // Disable (power off) the display disabling the common Anode pin
  45. digitalWrite(vccControlPin, LOW);
  46. Serial.println("- Display Off");
  47. delay(2000); // wait 2 sec
  48. }

You can find a pre-assembled daisy-chained four shift registers board or the PCB only at BalearicDynamics. Don’t forget to use the discount code ELEKTRO1008 to get 20% off discount, the special price for Electroschematics.com users.

الاثنين، 7 ديسمبر 2015

Arduino LCD Enhancement

The most popular display system widely used in Arduino projects is the liquid crystal display (LCD). LCD displays consists primarily of two sheets of polarized glass plates with a thin layer of liquid crystal solution sandwiched between them.

The type of liquid crystals used have very specific properties that enable them to serve as effective shutters that open and close to block or let light through in response to an electric current. The current through the liquid crystals is controlled by a voltage applied between the glass plates via transparent electrodes that form a grid, with rows on one side of the panel and columns on the other. As the electric current passes through these liquid crystals, they untwist to varying degrees, depending on the voltage applied. This untwisting effect will change the polarization of the light passing through the LCD panel. As the polarization changes in response to the applied voltage across the glass plates, more or less light is able to pass through the polarized filter on the face of the LCD.
16×2 Character LCD
The general purpose 16×2 Character LCD is very easy to interface with any microcontroller , and this LCD is really very cheap and thoroughly available in the whole world. The 16×2 Character LCD (based on HD44780 LCD Controller) uses 8 data bus lines (D0/DB0 – D7/DB7) and 3 control signals (E: Enable, RS: Register Select, R/W: Read/Write).
ALC-1
When interfacing with a microcontroller, VSS and VDD pins of the 16×2 Character LCD is connected to 0V (GND) and +5V (VCC) of the concerened circuit respectively. The V0 (also labelled as VEE) connection is for contrast control, and a potentiometer (10K) is usually attached to this terminal. Normally, the R/W terminal is tied to ground. For backlighting purpsoe, 5V dc supply is fed to the backlight pins BL1 and BL2 (also labelled as LED+/BL+ and LED-/BL-) through a suitable current limiting resistor (for instance, with a 100-Ohm one). All remaining connections of the 16×2 Character LCD are solely reserved for the microcontroller interface.
ALC-2
16×2 Character LCD & Arduino
You can find numerous “16×2 Character LCD and Arduino microcontroller” projects everywhere in this website. Instead of a new wheel around, this time we are focusing more on the backlight system of the 16×2 Character LCD. How to use an Arduino for controlling the backlight unit of a 16×2 Character LCD? In order to control the the backlight LED brightness, combination of a medium-power transistor (BC327) and Arduino’s pulse width modulation (PWM) feature to adjust the effective voltage supplied to the backlight LED is used here. The transistor serves as a current sink, and its base is connected to Arduino pin 3 (D3) to apply pulse width modulation control. The wiring diagram and sketch for a simple experiment is shown below.
ALC-3
  1. /* This sketch controls the backlight pin of the lcd, and fades the backlight in a pleasing style automatically */
  2. int bLED = 3;
  3. int brightness = 0;
  4. int fadeAmount = 5;
  5. void setup() {
  6. pinMode(led, OUTPUT);
  7. }
  8. void loop() {
  9. analogWrite(bLED, brightness);
  10. brightness = brightness + fadeAmount;
  11. if (brightness == 0 || brightness == 255) {
  12. fadeAmount = -fadeAmount ;
  13. }
  14. delay(300);
  15. }
Next is a different sketch to turn on (and flash) the backlight only when ambient light level is very low. Little additonal hardware is required here, so refer its wiring diagram shown after the sketch. Note that you should alter the analog value in the line ‘if (lightsensorValue >= 512)’ according to your own specific light sensor hardware.
  1. #define lightsensor 0 // photoresistor-LDR- input pin A0
  2. #define backlight 3 //backlight output pin D3
  3. int lightsensorValue;
  4. void setup() {
  5. pinMode(backlight, OUTPUT);
  6. digitalWrite(backlight, LOW);
  7. }
  8. void loop(){
  9. lightsensorValue = analogRead(lightsensor);
  10. if (lightsensorValue >= 512) // see note
  11. {
  12. digitalWrite(backlight, HIGH);
  13. delay (2000);
  14. digitalWrite(backlight, LOW);
  15. delay (1000);
  16. } else {
  17. digitalWrite(backlight, LOW);
  18. }
  19. }
ALC-4
This is the photograph of the 16x2 Character LCD, modified and used by author for all experiments described here.
This is the photograph of the 16×2 Character LCD,
modified and used by author for all experiments described here.
16×2 Character LCD – Contrast Control
As noted, contrast level of the LCD can be varied by varying the bias voltage on its pin 3 (V0/VEE). For this, we added a small potentiometer to this pin to control the contrast level to optimum/desired level. However, if you want a fixed contrast level then you can replace the potentiometer component with a resistor-diode setup as shown below. This gives a solid DC level (0.65/0.7 V) at the input of the Vo pin (contrast adjust) on the LCD.
ALC-6
Like the backlight, with the help of a little hardware, software-controlling of lcd contrast is also possible. This tutorial shows a way to control the backlight and contrast level in a 16×2 LCD via software with an Arduino, controlling the backlight turned on for certain time (which saves energy) and the contrast through buttons : http://garagelab.com/profiles/blogs/software-controlled-backlght-and-contrast-on-a-2×16-lcd-display
ALC-7
Be confident, this article helps you to fabricate your own microcontroller projects with enhanced display systems. With a little skill and patience you can add lcd backlight/contrast level control codes in your existing sketches. However, the ideas presented here cannot hope to cover every application. For this reason be prepared to do some experimenting to get the results you want!
Other Related Links:
http://www.jeremyblum.com/tutorial-13-for-arduino-liquid-crystal-displays/
http://www.freetronics.com.au/pages/lcd-keypad-shield-backlight-control
http://mind2move.com/m2m/arduino-lcd-shield/

Twitter Delicious Facebook Digg Stumbleupon Favorites More