CHAPTER 7 PIC microcontroller Examples

CHAPTER 7

Examples

Introduction

7.1 Supplying the microcontroller
7.2 LED diodes
7.3 Push buttons
7.4 Optocoupler
7.4.1 Optocouper on input line
7.4.2 Optocoupler on output line
7.5 Relay
7.6 Generating sound
7.7 Shift registers
7.7.1 Input shift register
7.7.2 Output shift register
7.8 7-seg display (multiplexing)
7.9 LCD display
7.10 Software SCI communication

Introduction

Examples given in this chapter will show you how to connect the PIC microcontroller with other peripheral components or devices when developing your own microcontroller system. Each example contains detailed description of hardware with electrical outline and comments on the program. All programs can be taken directly from the 'MikroElektronika' Internet presentation.

7.1 Supplying the microcontroller

Generally speaking, the correct voltage supply is of utmost importance for the proper functioning of the microcontroller system. It can easily be compared to a man breathing in the air. It is more likely that a man who is breathing in fresh air will live longer than a man who's living in a polluted environment.
For a proper function of any microcontroller, it is necessary to provide a stable source of supply, a sure reset when you turn it on and an oscillator. According to technical specifications by the manufacturer of PIC microcontroller, supply voltage should move between 2.0V to 6.0V in all versions. The simplest solution to the source of supply is using the voltage stabilizer LM7805 which gives stable +5V on its output. One such source is shown in the picture below.

01

In order to function properly, or in order to have stable 5V at the output (pin 3), input voltage on pin 1 of LM7805 should be between 7V through 24V. Depending on current consumption of device we will use the appropriate type of voltage stabilizer LM7805. There are several versions of LM7805. For current consumption of up to 1A we should use the version in TO-220 case with the capability of additional cooling. If the total consumption is 50mA, we can use 78L05 (stabilizer version in small TO - 92 packaging for current of up to 100mA).