Professional Documents
Culture Documents
Author: A.Siva
Reviewers:
Introduction:
MPLAB Xpress IDE cost free development platform. Its cloud Based IDE available from
microchip supporting PIC-based microcontrollers. The platform is comprised of code editor,
build automation tools, debugger, code configurator. MPLAB Xpress IDE is an end-to-end
solution enabling engineers to develop their applications from initial evaluation to final
production.
Component required:
Hardware required:
1) MPLAB xpress Evaluation Board
2) LED
3) USB mini-B cable.
4) Potentiometer(POT)
Software required:
1) MPLAB Xpress IDE
Note:
On board LEDs available(PORTA-0,1,3,4 pins)
On board POT available (PORTA-4 pin)
Step 2: start creating our new project. Go to File >> New Project. Select microchip embedded
as well as standalone project then click next
Step 5: Now choose mplab xpress code configurator if its not present in your Device please
Download and install from following link. http://www.microchip.com/mplab/mplab-codeconfigurator
Step 6: Now we can see our mplab xpress configuration window and select system module
in mplab xpress configuration window .
Step 7: select pin module in mplab xpress configuration window and make deselect Analog
in pin module window.
Note: If you didnt done above things please add all library files.
SOURCE CODE:
#include "mcc_generated_files/mcc.h
void delay_ms(unsigned int milliseconds)
{
while (milliseconds > 0)
{
__delay_ms(1);
milliseconds--;
}
}
void led_Toggle(short j)
{
switch (j)
{
case 1: led1_Toggle();
break;
case 2: led2_Toggle();
break;
case 3: led3_Toggle();
break;
case 4: led4_Toggle();
break;
}
}
void led_SetLow(short j)
{
switch (j)
{
//delay function
case 1: led1_SetLow();
break;
case 2: led2_SetLow();
break;
case 3: led3_SetLow();
break;
case 4: led4_SetLow();
break;
}
}
void led_SetHigh(short j)
{
switch (j)
{
case 1: led1_SetHigh();
break;
case 2: led2_SetHigh();
break;
case 3: led3_SetHigh();
break;
case 4: led4_SetHigh();
break;
}
}
void main(void)
{
SYSTEM_Initialize();
int ledPos = 0;
int dir = 0;
unsigned int potval;
while (1) {
if (!button_GetValue()) {
dir = !dir;
ledPos = 5;
while (--ledPos > 0)
led_SetLow(ledPos);
}
if (dir)
{
ledPos++;
if (ledPos > 4)
ledPos = 1;
}
else
{
ledPos--;
if (ledPos < 1)
ledPos = 4;
}
led_Toggle(ledPos);
potval = ADCC_GetSingleConversion(pot);
delay_ms(potval / 100);
}
}
Step 9: Go to your MPLAP xpress IDE Erase all existing code and copy above code past there
and add header file from given file then make clean and build for Export . if you done this go
to download you can see hex file for your project.
Step 10: Now, if all goes well connect the Micro B cable to pic16f18855 (MPLAB Xpress
demonstration board) and connect it to your computer. If you done you can see your devise.
And copy that Hex file to your device. And make hardware connection.
OUTPUT:
figure 12 output