Emmanuel Egyin
Published © GPL3+

Smart LED Sequence Controller with OLED Display

A PIC16F877A-based embedded system that controls sequential LED animations while providing real-time visual feedback through an OLED display

IntermediateFull instructions provided6 hours18
Smart LED Sequence Controller with OLED Display

Things used in this project

Hardware components

PIC16F
Microchip PIC16F
×1
0.96" OLED 64x128 Display Module
ElectroPeak 0.96" OLED 64x128 Display Module
×1
LED, RGB
LED, RGB
×1
LED (generic)
LED (generic)
×8
Buzzer
Buzzer
×1
8 MHz Crystal
8 MHz Crystal
×1
Resistor 10k ohm
Resistor 10k ohm
×1
Resistor 220 ohm
Resistor 220 ohm
×3
Through Hole Resistor, 330 kohm
Through Hole Resistor, 330 kohm
×8
Capacitor 22 pF
Capacitor 22 pF
×2

Software apps and online services

Proteus Professional
MPLAB X IDE
Microchip MPLAB X IDE

Hand tools and fabrication machines

PCB Holder, Soldering Iron
PCB Holder, Soldering Iron

Story

Read more

Custom parts and enclosures

PIC16F877A OLED-Based Sequential LED Controller with RGB Status Indicator

A custom embedded controller built around the PIC16F877A microcontroller featuring sequential LED animation, OLED user feedback, RGB status indication, buzzer alerts, PCB design, and full Proteus simulation.

Schematics

PIC16F877A OLED-Based Sequential LED Controller with RGB Status Indicator

A custom embedded controller built around the PIC16F877A microcontroller featuring sequential LED animation, OLED user feedback, RGB status indication, buzzer alerts, PCB design, and full Proteus simulation.

Code

Smart LED Sequence Controller with OLED Display Summary

C/C++
Create a hex. file out of the code from MPLAB X IDE and uploade it to the microcontroller program.
#include <xc.h>

#define _XTAL_FREQ 4000000

// CONFIGURATION BITS
#pragma config FOSC = HS
#pragma config WDTE = OFF
#pragma config PWRTE = ON
#pragma config BOREN = ON
#pragma config LVP = OFF
#pragma config CPD = OFF
#pragma config WRT = OFF
#pragma config CP = OFF

// LCD CONTROL PINS
#define RS RC0
#define EN RC1

void pulse_enable()
{
    EN = 1;
    __delay_ms(2);
    EN = 0;
}

void lcd_cmd(unsigned char cmd)
{
    PORTC &= 0x0F;

    PORTC |= (cmd & 0xF0);

    RS = 0;

    pulse_enable();

    PORTC &= 0x0F;

    PORTC |= ((cmd << 4) & 0xF0);

    pulse_enable();

    __delay_ms(2);
}

void lcd_data(unsigned char data)
{
    PORTC &= 0x0F;

    PORTC |= (data & 0xF0);

    RS = 1;

    pulse_enable();

    PORTC &= 0x0F;

    PORTC |= ((data << 4) & 0xF0);

    pulse_enable();

    __delay_ms(2);
}

void lcd_init()
{
    __delay_ms(20);

    lcd_cmd(0x02);
    lcd_cmd(0x28);
    lcd_cmd(0x0C);
    lcd_cmd(0x06);
    lcd_cmd(0x01);
}

void lcd_string(const char *str)
{
    while(*str)
    {
        lcd_data(*str++);
    }
}

void main(void)
{
    int i;

    TRISD = 0x00;
    TRISB = 0x00;
    TRISC = 0x00;

    PORTD = 0x00;
    PORTB = 0x00;
    PORTC = 0x00;

    lcd_init();

    lcd_string("LED CHASER");

    while(1)
    {
        for(i = 0; i < 8; i++)
        {
            PORTD = (1 << i);

            // RGB CONTROL
            if(i % 3 == 0)
            {
                PORTB = 0x01;
            }
            else if(i % 3 == 1)
            {
                PORTB = 0x02;
            }
            else
            {
                PORTB = 0x04;
            }

            // BUZZER
            RB3 = 1;
            __delay_ms(50);

            RB3 = 0;
            __delay_ms(200);
        }
    }
}

Credits

Emmanuel Egyin
2 projects • 0 followers
Electrical engineer building reliable emberded systems that turn ideas into working hardware fast.

Comments