PICexamples
PICexamples
To make a specific bit of the port as input or output, we can use the following code:
In the input mode of Port A, the status of the pins can be read by reading the PORTA register.
First, we need to set the direction of data by setting the TRISA bit to 1, which makes the
corresponding PORTA pin an input and puts the corresponding output driver in a Hi-Impedance
mode. Example code:
In the output mode of Port A, we need to set the direction of data using the TRISA register and
assign a value to the port for output. A write to the PORT register writes the data value to the
port latch. Example code:
3. LAT Register
The LAT (Latch) register is associated with an I/O pin and eliminates the problems that could
occur with read-modify-write instructions.
Latch Read
A read of the LAT register returns the values held in the port output latches instead of the values
on the I/O pins.
Latch Write
A write to the LAT register has the same effect as a write to the PORT register. A write to the
PORT register writes the data value to the port latch.
ANSEL and ANSELH
There are several registers that affect the operation of the digital I/O pins. If you look at the pin
diagram you will see that pin 3 is called RA4/AN3. This is because it can serve as digital I/O port
RA4, or analog input pin AN3. The two registers ANSEL and ANSELH control whether or not
AN0 through AN11 are operational. Each bit in the register controls one pin as outlined in the
register tables shown below. A '0' sets the pin to digital mode and a '1' sets the pin to analog mode.
For example, if you make ANSEL equal to 0b10000001 (binary), then AN7 will be enabled and
RC3 will be disabled because they share the same pin (pin 7). AN0 will also be in analog mode
(RA0 disabled). Reading a pin that is set to analog mode will return a '0'.
We will make the first 2 bits of PORTA as inputs and the next 6 bits as outputs.
We will make the first 5 bits of PORTB as outputs and the last 3 bit as inputs.
TRISA= 0b00000011;
TRISB= 0b11100000;
Remember that the first bits appear to the rightmost, since the most significant bit (RA7 or RB7) is
leftmost.
As another example, to make all bits in PORTA inputs and all bits in PORTB outputs, we use the
following code below.
TRISA= 0b11111111;
TRISB= 0b00000000;
The advantage of setting a PORT with hexadecimal values is that the number used is shorter than if
using other number formats.
The disadvantage is that many times it requires calculation or some type of converter to know the value
that must be used, but with practice, a programmer may know what codes correspond to what
We will make the first 2 bits of PORTA as inputs and the next 6 bits as outputs.
We will make the first 5 bits of PORTB as outputs and the last 3 bit as inputs.
TRISA= 0x3;
TRISB= 0xE0;
To make all bits in PORTA inputs and all bits in PORTB outputs, we use the following code below.
TRISA= 0xFF;
TRISB= 0x00;
Now all bits in PORTA are inputs and all bits in PORTB are outputs.
PIC is a Peripheral Interface Microcontroller which was developed in the year 1993 by the General
Instruments Microcontrollers. It is controlled by software and programmed in such a way that it
performs different tasks and controls a generation line. PIC microcontrollers are used in different
new applications such as smartphones, audio accessories, and advanced medical devices.
CHASING LEDS
============
In this project 8 LEDs are connected to PORTC of a PIC18F45K22 microcontroller and the
microcontroller is operated from an 8 MHz crystal.
The program turns ON the LEDs in an an�clockwise manner with 1 s delay between
each output. The net result is that LEDs seem to be chasing each other.
**************************************************************************/
void main()
{
unsigned char J = 1;
ANSELC = 0; // Configure PORTC as digital
TRISC = 0; // Configure PORTC as output
for(;;) // Endless loop
{
PORTC = J; // Send J to PORTC
Delay_ms(1000); // Delay 1 s
J = J << 1; // Shi�_ le�_ J
if(J == 0) J = 1; // If last LED, move to first one
}
}
If you are using the EasyPIC V7 development board, then make sure that the following
jumper is configured:
DIP switch SW3: PORTC ON
In this project 8 LEDs are connected to PORTC of a PIC18F45K22 microcontroller and the
microcontroller is operated from an 8 MHz crystal.
The program uses a pseudorandom number generator to generate a number between 0 and
32767. This number is then divided by 128 to limit it between 1 and 255. The resultant number
is sent to PORTC of the microcontroller. This process is repeated every second.
*****************************************************************************/
void main()
{
unsigned int p;
ANSELC = 0; // Configure PORTC as digital
TRISC = 0; // Configure PORTC as output
srand(10); // Ini�alize random number seed
for(;;) // Endless loop
{
p = rand(); // Generate a random number
p = p / 128; // Number between 1 and 255
PORTC = p; // Send to PORTC
Delay_ms(1000); // 1 s delay
}
}
DIP switch SW3: PORTC ON
LED BLINKING
====================
In this project 8 LEDs are connected to PORTB of a PIC18F45K22 microcontroller and the
microcontroller is operated from an 8 MHz crystal.
The program toggles the outputs at every second.
*****************************************************************************/
void main() {
// set PORTB to be digital output
TRISB = 0;
// Turn OFF LEDs on PORTB
LATB = 0;
while(1) {
// Toggle LEDs on PORTB
LATB = ~LATB;
// Delay 1000 ms
Delay_ms(1000);
}
}
DIP switch SW3: PORTB ON
PUSH BUTTON
====================
In this project RC0 of PORTC is connected to a push buton switch, RB0 of PORTB is connected
to an LED through a resistor. and the PIC18F45K22 microcontroller is operated from an 8 MHz
crystal. While and whenever the switch is pressed, the LED goes high.
*****************************************************************************/
void main() {
TRISC.RC0 = 1; //Configure 1st bit of PORTC as input
TRISB.RB0 = 0; //Configure 1st bit of PORTB as output
PORTB.RB0 = 0; //LED OFF
do
{
if(PORTC.RC0 == 1) //Check whether the switch is pressed
PORTB.RB0 = 1; //LED ON
else
PORTB.RB0 = 0; //LED OFF
}while(1);
}
DIP switch SW3: PORTB and PORTC ON, and PULLDOWN RC0
LED PROBE
====================
This is a logic probe project. In this project 2 colored LEDs are connected to PORTC pins RC6 (RED)
and RC7 (GREEN). In addi�on, RC0 is used as the probe input. If the logic probe is at logic 1 then
the RED LED is turned ON. Otherwise, the GREEN LED is turned ON.
*****************************************************************************/
#define PROBE PORTC.RC0
#define RED_LED PORTC.RC6
#define GREEN_LED PORTC.RC7
void main()
{
ANSELC = 0; // Configure PORTC as digital
TRISC0_bit = 1; // Configure RC0 as input
TRISC6_bit = 0; // Configure RC6 as output
TRISC7_bit = 0; // Configure RC7 as output
for(;;) // Endless loop
{
if(PROBE == 1) // If the signal is HIGH
{
GREEN_LED = 0; // Turn OFF GREEN LED
RED_LED = 1; // Torn ON RED LED
}
else
{
RED_LED = 0; // Turn OFF RED LED
GREEN_LED = 1; // Turn ON GREEN LED
}
}
}
To correct the problem in the code, insert a delay after each PORTB.Bx = 1 line, or modify the entire
PORTB register in a single line PORTB = 0b00000011.
This is a LED dice project. In this project 6 LEDs are connected to PORTB to represent the number
1 to 6. In addi�on, RC0 is used as the roll switch. If the dice is rolled, that means switch at RC0 is
pressed, the random number 1 through 6 is generated and corresponding output will appear at
the PORTB.
*****************************************************************************/
void main()
{
unsigned char digit;
unsigned char Dice[]={0,0x01, 0x03, 0x07,0x0F,0x1F,0x3F};
ANSELB = 0; // Configure PORTD as digital
ANSELC = 0; // Configure PORTC as digital
TRISB = 0; // Configure PORTD as outputs
TRISC = 0x01; // Configure RC.0 of PORTC as input
srand(10);
for(;;)
{
if(PORTC.RC0 == 1)
{digit=rand()%6+1;
PORTB=Dice[digit];
Delay_Ms(3000);
PORTB=0;}
}
}
DIP switch SW3: PORTB and PORTC ON and PULLDOWN RC0
BUZZERS
Buzzers can be categorized into two different types – active buzzers and passive buzzers. An active
buzzer has a built-in oscillator so it can produce sound with only a DC power supply.
A passive buzzer does not have a built-in oscillator, so it needs an AC audio signal to produce
sound.
ACTIVE BUZZERS
Active buzzers are the simplest to use. They are typically available in voltages from 1.5V to 24V.
All you need to do is apply a DC voltage to the pins and it will make a sound.
Active buzzers have polarity. The polarity is the same as an LED and a capacitor – the longer pin
goes to positive. One downside of active buzzers is that the frequency of the sound is fixed and
cannot be adjusted.
PASSIVE BUZZERS
Passive buzzers need an AC signal to produce sound. the downside to this is that they will need
more complex circuitry to control them, like an oscillating 555 timer or a programmable
microcontroller like the Arduino.
Passive buzzers have the advantage that they can vary the pitch or tone of the sound. Passive
buzzers can be programmed to emit a wide range of frequencies or musical notes.
BUZZER
============
void main() {
ANSELC=0;
TRISC=0;
PORTC=0;
for(;;)
{unsigned int i,j,k;
for(i=0;i<80;i++)
{PORTC.RC2=1;
Delay_ms(1);
PORTC.RC2=0;
Delay_ms(1);}
for(j=0;j<80;j++)
{ PORTC.RC2=1;
Delay_ms(2);
PORTC.RC2=0;
Delay_ms(2);}
}
}
J21: Select RC2
Generating Sound
====================
This project shows how sound with different frequencies can be generated using a simple
buzzer. The project shows how the simple melody “Happy Birthday” can be played using a
buzzer.
Normally, buzzers are excited using square wave signals, also called Pulse Width
Modulated (PWM) signals. The frequency of the signal determines the pitch of the generated
sound, and duty cycle of the signal can be used to increase or decrease the volume. Most
buzzers operate in the frequency range 2-4 kHz. The PWM signal required to generate sound
can be using the PWM module of the PIC microcontrollers.
When playing a melody, each note is played for a certain duration and with a certain
frequency. In addition, a certain gap is necessary between two successive notes. The
frequencies of the musical notes starting from middle C (i.e. C4) are given below. The harmonic
of a note is obtained by doubling the frequency. For example, the frequency of C5 is 2 x 262 =
524 Hz.
mikroC Pro for the PIC compiler provides a sound library with the following two functions:
Sound_Init This function is used to specify to which port and which pin the sound device is
connected to
Sound_Init(char *snd_port, char snd_pin)
Eg., Sound_Init(&PORTC, 3);
Sound_Play This function generates a square wave signal with the specified frequency
(hertz) and duration (milliseconds) from the port pin specified by the
initialization function. The frequencies given in the above table are
approximated to their nearest integers since this function accepts only integer
frequencies.
Sound_Play(unsigned freq_in_hz, unsigned duration_ms);
Eg., Sound_Play(698, 250); // Frequency = 698Hz, duration = 250ms
Hz 261.63 277.18 293.66 311.13 329.63 349.23 370 392 415.3 440 466.16 493.88
PLAYING MELODY
================
In this project a buzzer is connected to port pin RC2 of a PIC18F45K22 microcontroller,
operating with an 8 MHz crystal.
The program plays the classical "Happy Birthday" melody.
**************************************************************/
#define Max_Notes 25
void main()
{
unsigned char i;
unsigned int Notes[Max_Notes] =
{
262, 262, 294, 262, 349, 330, 262, 262, 294, 262, 392,
349, 262, 262, 524, 440, 349, 330, 294, 466, 466, 440,
349, 392, 349
};
unsigned char Durations[Max_Notes] =
{
1, 1, 2, 2, 2, 3, 1, 1, 2, 2, 2, 3, 1, 1, 2, 2, 2, 2, 2,
1, 1, 2, 2, 2, 3
};
ANSELC = 0; // Configure PORTC as digital
Sound_Init(&PORTC, 2); // Initialize the Sound library
for(;;) // Endless loop
{
for(i = 0; i < Max_Notes; i++) // Do for all notes
{
Sound_Play(Notes[i], 400*Durations[i]); // Play the notes
Delay_ms(100); // Note gap
}
Delay_Ms(3000); // Repeat after 3 s
}
}
J21: Select RC2
ABCsound
=========
In this project a buzzer is connected to port pin RC2 of a PIC18F45K22 microcontroller,
operating with an 8 MHz crystal.
The program plays the classical "ABC" melody.
**************************************************************/
void main()
{
unsigned char i;
unsigned int fst[7] ={262,262,392,392,440,440,392};
unsigned int snd[7]={349,349,330,330,294,294,262};
unsigned int thd[3]={392,392,349};
unsigned int fot[3]={330,330,294};
unsigned int fit[7]={262,262,392,392,440,440,392};
unsigned int sit[7]={349,349,330,330,294,294,262};
void main()
{
unsigned char digit;
ANSELA = 0; // Configure PORTA as digital
ANSELD = 0; // Configure PORTD as digital
TRISA = 0; // Configure PORTA as outputs
TRISD = 0; // Configure PORTD as outputs
DIGIT1 = 0; // Disable digit 1
for(;;)
{ for(digit=0; digit<10;digit++)
{PORTD=Display(digit);
DIGIT1=1;
Delay_Ms(1000);
DIGIT1=0;}
}
}
7 Seg Dice
====================
#define DIGIT1 PORTA.RA0
unsigned char Display(unsigned char i)
{unsigned char segment[]={0x3F, 0x06, 0x5B,0x4F,0x66,0x6D,0x7D,0X07, 0x7F,0x6F};
unsigned char patern;
patern=segment[i];
return (patern);}
void main()
{
unsigned char digit;
ANSELA = 0; // Configure PORTA as digital
ANSELD = 0; // Configure PORTD as digital
ANSELC = 0; // Configure PORTC as digital
TRISA = 0; // Configure PORTA as outputs
TRISD = 0; // Configure PORTD as outputs
TRISC = 0x01; // Configure RC.0 of PORTC as input
DIGIT1 = 0; // Disable digit 1
srand(10);
for(;;)
{
if(PORTC.RC0 == 1)
{digit=rand()%6+1;
PORTD=Display(digit);
DIGIT1=1;
Delay_Ms(1000);
DIGIT1=0;}
}
}
7 Seg Cascading
====================
*** Every interrupt request have an interrupt handler otherwise called Interrupt Service Routine
(ISR). The microcontroller runs the ISR on every interrupt request.
*** For every interrupt, there is a fixed location in memory that holds the ADDRESS of its ISR.
These group of memory location is called INTERRUPT VECTOR TABLE.
Interrupts can occur either ASYNCHRONUOSLY (External Events) or SYNCHRONUOSLY
(usually Timer Interrupt).
Timer 0
Control register
Each timer has a control register called TCON to set the various timer operation modes.
T0CON is an 8-bit register used for control of timer 0.
TMR0ON (Timer0 on/off control bit)
1 = Enable timer 0
0 = Disable timer 0
T08BIT (Timer0 8-bit/16-bit control bit)
1 = Configured as an 8-bit timer/counter
0 = Configured as an 16-bit timer/counter
T0CS (Timer0 clock source select bit)
1 = Transition on T0CKL pin
0 = Internal instruction cycle clock (CLK0) [It means Fosc/4]
T0SE (Timer0 Source Edge select bit)
1 = High to Low transition on T0CKL pin
0 = Low to High transition on T0CKL pin
PSA (Timer0 Prescaler assignment bit)
1 = Timer 0 Prescaler is not assigned
0 = Timer 0 Prescaler is assigned
T0PS2 - T0PS0 (Timer0 prescaler select bit)
111 - 1:256 prescaler value
110 - 1:128 prescaler value
101 - 1:64 prescaler value
100 - 1:32 prescaler value
011 - 1:16 prescaler value
010 - 1:8 prescaler value
001 - 1:4 prescaler value
000 - 1:2 prescaler value
Load register
*** For the same interrupt to re-occur, the completion status has to be cleared that is; T0IF=0
(Timer 0 Interrupt Flag) and the Timer Value reloaded into the timer register.
Note: By loading TMR0 Register we can control the count until an overflow occurs (interrupt
takes place)
*** In PIC microcontroller instruction takes 4 clock cycles, that’s why you see crystal clock being
divided by 4.
Assuming we have PIC 16F877A microcontroller using an external clock of 8 MHz and we are
required to generate 200 microseconds interrupt with a Prescaler value of 2. The TMRO Value
will be 56 using the above formula.
Internal Oscillator Frequency = 8MHz / 4 = 2MHz
As the timer increments and when it reaches to its maximum value of 255, it will trigger an
interrupt and initialize itself to 0 back again. This interrupt is called as the Timer Interrupt. This
interrupt informs the MCU that this particular time has lapped.
Timmer 0 Interrupt
====================
TRISD = 0x00;
TRISB = 0x00;
// clear output bit
LATD = 0x00;
LATB = 0x00;
InitTimer0();
while (1) {
task_1 (); //blinks every 200ms
task_2 (); // blinks every 1 sec
}
}
void Interrupt(){
if (TMR0IF_bit){
TMR0IF_bit = 0;
TMR0H = 0x0B;
TMR0L = 0xDC;
digit++; //Enter your code here
if(digit==60) digit=0;
}
}
#define DIGIT1 PORTA.RA0
#define DIGIT2 PORTA.RA1
unsigned char Display(unsigned char i)
{unsigned char segment[]={0x3F, 0x06, 0x5B,0x4F,0x66,0x6D,0x7D,0X07, 0x7F,0x6F};
unsigned char patern;
patern=segment[i];
return (patern);}
void main()
{int lsb=0,msb=0,i=0,flag=0; // variable i is for counter & flag for delay
ANSELA = 0; // Configure PORTA as digital
ANSELD = 0; // Configure PORTD as digital
TRISA = 0; // Configure PORTA as outputs
TRISD = 0; // Configure PORTD as outputs
DIGIT1 = 0; // Disable digit 1
DIGIT2=0;
PORTD=0X00;
InitTimer0();
for(;;)
{ lsb=digit%10;
msb=digit/10;
PORTD=Display(msb);
DIGIT2=1;
Delay_Ms(5);
DIGIT2=0;
PORTD=Display(lsb);
DIGIT1=1;
Delay_Ms(5);
DIGIT1=0;
}
}
Arduino TimmerInterrupt
https://deepbluembedded.com/arduino-timer-interrupts/
External Interrupt
=====================
Types of interrupts
There are two methods of communication between the microcontroller and the external device:
• By using Polling
• By using Interrupts
POLLING
In this method, the external devices are not independent. We fix the time interval in which
microcontroller has to contact the external device. The microcontroller accesses that device at the
exact time interval and gets the required information. Polling method is just like picking up our
phone after every few seconds to see if we have a call. The main drawback of this method is the
waste of time of microcontroller. It needs to wait and check whether the new information has
arrived not.
INTERRUPTS IN PIC18F452
Following interrupts sources are present in PIC18F452
• Timer over interrupt
• Pins RB0, RB1, RB2 for external hardware interrupts (INT0, INT1, INT2)
• PORTB Change interrupts (any one of the upper four Port B pins. RB4-RB7)
• ADC (analog-to-digital converter) Interrupt
• CCP (compare capture pulse-width-modulation) Interrupt
• Serial communication’s USART interrupts (receive and transmit)
• Reset, Brown-Out Reset, Watch-dog Reset, Power On Reset
• Parallel Port Read/Write Interrupt
• Master Synchronous Serial Port Interrupt
• Data EEPROM Write Complete Interrupt
RCON Register:
• Reset control register
• IPEN bit to enable interrupt priority scheme, 1= enable priority level on interrupts
• Other bits used to indicate the cause of reset
RI (Reset Instruction flag), TO (Watchdog Time Out flag), PD (Power on Detection flag), POR
(Power on Reset status) and BOR (Brown Out Reset status bit)
INTCON Register:
• 3 Interrupt control registers INTCON, INTCON2, INTCON3
• Readable and writable register which contains various enable and flag bits
• Interrupt flag bits get set when an interrupt condition occurs
• Contain enable, priority and flag bits for external interrupt, port B pin change and TMR0
overflow interrupt
PIE Register:
• Peripheral Interrupt Enable register
• May be multiple register (PIE1, PIE2), depending on the number of peripheral interrupt sources
• Contain the individual bits to enable/disable Peripheral interrupts for use
PIR Register:
• Peripheral Interrupt Flag register
• May be multiple register (PIR1, PIR2), depending on the number of peripheral interrupt
sources
• Contain bits to identify which interrupt occurs (flags)
• Corresponding bits are set when the interrupt occurred
INTCON REGISTER:
GIE: Global Interrupt Enable
This bit is set high to enable all interrupts of PIC18F452.
1 = Enable all interrupts
0 = Disable all interrupts
INTCON2 REGISTER:
INTCON3 REGISTER:
INT1IP, INT2IP:
These bits are used to set priority of the interrupts 1 and 2, respectively.
1 = High priority
0 = Low priority
Bit 5, Bit 2:
Both are unimplemented and read as 0.
INT1IE, INT2IE:
These bits enable/disable the External Interrupt 1 and 2, respectively.
1 = Enables the External Interrupt x
0 = Disables the External Interrupt x
INT1IF, INT2IF:
These are External Interrupt 1 and 2 flag bits, respectively.
1 = The INTx External Interrupt occurred (must be cleared in software)
0 = The INTx External Interrupt did not occur
External Interrupt1
Working Principal:
PORT D LEDs will on as 10101010. When button at RB1 is pushed, interrupt service routine will
start. It will invert (or toggle) the output at PORTD. After 1 sec while loop will again start.
Code:
void main()
{
ANSELB = 0; // Configure PORT B pins as digital
ANSELD = 0; // Configure PORT D pins as digital
TRISB = 2; // Set PORT B (only RB1) as input
TRISD = 0; // Set PORT D as output
LATD = 0x00; // Set all pin on PORT D Low
}
}
External Interrupt2
Working Principal:
This is a simple interrupt demonstration project. All LEDs on PORTD will flash until interrupt
occurs (RB0 is pressed).Interrupt will set local flag, which will cause Flashing routine to be
executed.
/* NOTES:
- Put J17 in VCC position.
- Turn ON the PORT D LEDs at SW3.4.
- Put PORTB dip switch RB0 in PullDown position
*/
bit flag;
void Delay250() {
Delay_ms(250);
}
void Delay150() {
Delay_ms(150);
}
void main() {
flag = 0; // Varialbe initialisation
ANSELB = 0; // Configure PORT B pins as digital
ANSELD = 0; // Configure PORT D pins as digital
TRISB = 1; // Set PORT B (only RB0) as input
TRISD = 0; // Set PORT D as output
LATD = 0x00; // Set all pin on PORT D Low
while(1) {
LATD = 0xFF; // Set all pin on PORT D High
Delay250(); // Wait for some time
LATD = 0x00; // Set all pin on PORT D Low
Delay150(); // Wait for some time
if(flag) { // Checks local interrupt flag
FlashD1(); // Do something
flag = 0; // Resert local interrupt flag
}
}
}
External Interrupt3
Working Principal:
All LEDs on PORTD will remain LOW at the beginning. To initialize the program, the interrupt
signal must appear at RB1. After that, three flashing patterns can be changed from one to another
by pressing switch connected to RB1.
int count;
void interrupt() // Interrupt Service Routine
{ if(INT1F_bit == 1 )
{ count+=1;
delay_ms(200);
INT1F_bit = 0; // Clear the interrupt 0 flag
if(count==4) count=1; //Assign flag as 1;
}
}
void main()
{ char J=1;
int i=0;
char L[]={0x01,0x03,0x07,0x0F,0x1F,0x3F,0x7F,0xFF};
char R[]={0x7F,0x3F,0x1F,0x0F,0x07,0x03,0x01,0x00};
count=0;
ANSELB = 0; // Configure PORT B pins as digital
ANSELD = 0; // Configure PORT D pins as digital
TRISB = 2; // Set PORT B (only RB1) as input
TRISD = 0; // Set PORT D as output
LATD = 0x00; // Set all pin on PORT D Low
Digital signals have two discrete states, which are decoded as high and low, and interpreted
as logic 1 and logic 0. Analog signals, on the other hand, are continuous, and can have any value
within defined range. A/D converters are specialized circuits which can convert analog signals
(voltages) into a digital representation, usually in form of an integer number. The value of this
number is linearly dependent on the input voltage value. Most microcontrollers nowadays
internally have A/D converters connected to one or more input pins. Some of the most important
parameters of A/D converters are conversion time and resolution. Conversion time determines how
fast can an analog voltage be represented in form of a digital number. This is an important
parameter if you need fast data acquisition. The other parameter is resolution. Resolution
represents the number of discrete steps that supported voltage range can be divided into. It
determines the sensitivity of the A/D converter.
ADC1
Working Principle:
This program reads the analogue value from RB0 and display the corresponding value.
ADC2
Working Principle:
This program reads the analogue value from RB0 and convert to the corresponding voltage.
Finally, display the result.
Working Principle:
This program senses the surrounding temperature with the help of LM35 sensor. Finally, display
the result in degree Celsius.