Technology

LED Blinking with PIC Development Board

The PIC development board is a tool used for designing and testing prototypes of microcontrollers. Using the output pins available on the PIC board, you can design various circuits and control different devices through these pins. This article will explain step by step how to blink an LED using the PIC development board.

Materials:

  • PIC development board
  • LED
  • 220 ohm resistor
  • Jumper wires

Ad Area

More

Step 1: Connect the LED and resistor. We will use an output pin on the PIC board for the LED connection. We will use a resistor to limit the current needed for the LED to light up. Connect the 220 ohm resistor to the pin on the same row as the LED's anode (long leg). Connect the LED's cathode (short leg) to the ground pin.

Step 2: Prepare the software. To blink the LED, you need to load a program onto the PIC board. For programming, you will need PIC programming software and a PIC programming device. The PIC programming software allows you to upload the code you wrote to the PIC board and control its behavior.

Ad Area

More

Open the following code with PIC programming software and upload it to the PIC board.

#include <xc.h>

#pragma config FOSC = INTOSCIO // Internal oscillator
#pragma config WDTE = OFF // Watchdog timer disabled
#pragma config PWRTE = OFF // Power-up timer disabled
#pragma config MCLRE = ON // MCLR pin enabled
#pragma config CP = OFF // Code protection disabled
#pragma config CPD = OFF // Data code protection disabled
#pragma config BOREN = OFF // Brown-out reset disabled
#pragma config IESO = OFF // Internal/external oscillator switchover disabled
#pragma config FCMEN = OFF // Fail-safe clock monitor disabled

#define _XTAL_FREQ 4000000

void main()
{
    TRISAbits.TRISA0 = 0; // RA0 is output
    while (1) {
        PORTAbits.RA0 = 1; // LED on
        __delay_ms(500); // delay for 500ms
        PORTAbits.RA0 = 0; // LED off
        __delay_ms(500); // delay for 500ms
    }
}

This code sets the RA0 pin on the PIC board as an output and alternates the RA0 pin between high and low levels to blink the LED. The LED will blink on for 500 milliseconds and off for 500 milliseconds.

Ad Area

More
Tags:

Comments

Leave a Comment

You may also like

  • Games
  • 03-10-2024
  • 1 min. Read Time

Rise of Kingdoms Wheel Commanders

ISH SHELL - iOS Termux

Nedese

Nedese Panel

To start a free trial, all you need to do is go to the user management panel. Simplify your processes and increase your productivity with our tools tailored to your needs!

Start Your Free Trial
NedeseAI