From install to a blinking LED, and everything after.
PICPIO is a VS Code extension. Install it like any other:
Or press Ctrl+P and run:
ext install picpio.picpio
To build and flash real hardware, you also install Microchip's free tools (one time). PICPIO opens the right download pages for you on first run.
Check everything is found anytime by running picpio doctor in the PICPIO terminal.
PIC18F27K40), the programmer, and the framework:
TRISx/LATx/PORTx).src/main.c, a picpio.ini, and a REFERENCE.md with your chip's pin map and API.A PICPIO program has two functions: init() runs once at boot, and run() repeats forever.
#include <Picpio.h>
void init() { // runs once at startup
gpio_mode(BUILTIN_LED, GPIO_OUT);
}
void run() { // repeats forever
gpio_write(BUILTIN_LED, GPIO_HIGH);
sys_delay(500);
gpio_write(BUILTIN_LED, GPIO_LOW);
sys_delay(500);
}
That's a complete blink program. Pins are named D0–Dn, A0–An for analog, and BUILTIN_LED for the on-board LED.
Simple, consistent functions across every supported chip:
| Area | Functions |
|---|---|
| Digital I/O | gpio_mode(pin, GPIO_OUT|GPIO_IN), gpio_write(pin, GPIO_HIGH|GPIO_LOW), gpio_read(pin) |
| Analog in | adc_read(channel) → 0–1023 |
| PWM | pwm_write(pin, duty) |
| Timing | sys_delay(ms), sys_millis() |
| Serial (UART) | uart1.begin(115200), uart1.print(...), uart1.println(...) |
| I2C | i2c1.begin(), i2c1.write(...), i2c1.read(...) |
| SPI | spi1.begin(), spi1.transfer(...) |
Example: read a sensor and print it:
void init() {
uart1.begin(115200);
}
void run() {
int v = adc_read(A0); // 0..1023
uart1.println(v);
sys_delay(200);
}
REFERENCE.md lists the exact pin map and the full API for your chip, open it anytime.Use the PICPIO toolbar buttons, or the terminal:
Connect your board with a PICkit (or Snap/ICD), hit Upload, and watch it flash:
$ picpio upload
Compiling main.c with XC8...
Program: 3.1% Data: 1.4%
✓ Flashed to PIC18F27K40
✓ Done in 4.2s
PICPIO ships 130+ ready-made drivers: OLED/TFT displays, sensors, motor & stepper drivers, RTCs, ADC/DAC expanders, RF/CAN/LoRa, USB CDC serial, GPS/GSM, keypads, SD card (FAT16/32), EEPROM, WS2812 LEDs, servos, PID and more.
REFERENCE.md.$ picpio lib add SSD1306
✓ Added SSD1306 (I2C OLED)
✓ Example inserted into src/main.c
No board yet? Run your logic in the built-in simulator and watch it work.
src/main.c.Great for teaching, for checking logic, and for working without hardware in hand.
See live output from your board and send data back:
uart1.begin(...)).COM3 @ 115200
Temp: 24.6 C
Temp: 24.7 C
Humidity: 48%
Teaching or learning register-level PIC programming? Pick the bare-metal framework when creating a project. You write a normal main() against the chip's real SFRs, with full IntelliSense (autocomplete on TRISB, PORTAbits, …).
// bare-metal blink
void main(void) {
TRISBbits.TRISB0 = 0; // RB0 output
while (1) {
LATBbits.LATB0 ^= 1; // toggle
__delay_ms(500);
}
}
Every project includes a REFERENCE.md generated for your exact chip:
D0, A0, the I2C/SPI/UART pins…).It's read-only and always matches your hardware, keep it open as you build.
If a build or upload fails, run picpio doctor: it checks your whole toolchain and tells you what's missing:
$ picpio doctor
✓ XC8 compiler v2.46
✓ PICkit 3 detected
✓ Device pack installed
✓ 130+ libraries
All systems go.
picpio install-dfp once, then build again.