Saturday, September 24, 2022

Interfacing of LEDs with PIC microcontroller

Algorithm 

Step1: LEDs are connected in Port A of PIC microcontroller

Step2: Make Port A as output port

Step3: Making all LEDs glow by sending value “0F” at port A

Step4: After time delay of 500ms, turned off all LEDs by sending value of “00” at port A

Step5: After another 500ms delay, repeat steps 3



Circuit Diagram





Program code

 #include <pic.h> //Define PIC Registers

__CONFIG(0x3f72); //Select HS oscillator, Enable (PWRTE,BOREN), Turn OFF 

(CPD,CP,WDTEN,In-circuit Debugger).

void DelayMs(unsigned int);

void main()

{

ADCON1 = 7; //Select all the PORTA & PORTE as Digital I/O pins

TRISA = 0x00; //PORTA Configured as O/P

while(1)

{

PORTA = 0x0f; //Enable all the LED's connected to PORTA

DelayMs(500); //Half second Delay

PORTA = 0; //Turn OFF all the LED's connected to PORTA

DelayMs(500); //Half second Delay

}

}

void DelayMs(unsigned int Ms)

{

int delay_cnst;

while(Ms>0)

{

Ms--;

for(delay_cnst = 0;delay_cnst <220;delay_cnst++);

}

}

No comments:

Post a Comment

GPS sensor interface with ESP8266 using Blynk IoT cloud

   Circuit diagram: Source Code: #include <TinyGPS++.h> #include <SoftwareSerial.h> #define BLYNK_PRINT Serial #include <ESP8...