I recently converted to Microchip Tech PIC micro-controllers after using AVR from Atmel, I found myself enjoying the learning process and challenges that came with it. Getting my head around MPLAB is an on going process. I often see people bag MPLAB but honestly, it works. It’s not as nice as AVR Studio (which I’m use to given that I use Visual Studio too)

Developing for desktop applications then moving to micro controllers, I realised just how much more there was to learn and just how much some development environments hand to the developer, its easy to forget the back ground code that goes into a lot of functions. Moving to Microchip PIC / MPLAB X has meant that libraries that were otherwise provided by some IDE’s are not there so it means creating them. That’s not a bad thing I don’t think. At the end of the day it’s all part of learning.

7 Segment LED on a 74HC595 Shift Register.

7 Segment LED on a 74HC595 Shift Register.

Anyway, I started to use 7 segment LED’s and realised that running out of outputs on a smaller chip would happen really quick. I’ve played a little with Multiplexing and Charlieplexing (I recommend you Google both), however I used shift registers on Arduino and AVR in the past for LCD screens and LED’s so figured, can’t be that hard for the PIC.

Well, this is what I came up with. After putting a screen shot on G+ it has been slightly modified from the original and I’m sure there is still room for improvement. But it works for me on MPLAB X with XC8 on a PIC18F2550, though it should be easy enough to modify for any PIC micro-controller.

simply include the file, initialise_74HC595(); and then write_74HC595(LED_numbers[5]); to display the number 5 for example.

I hope this helps others out in their learning process, Understanding Bitwise operators is going to make life easier too. I have this same code but for Atmel AVR Studio if anyone is wanting an AVR version.

[code lang=”c”]/*
*