Tag Archives: mikroC

Lab 19: Play musical notes

We have discussed in the past experiments how to use a PIC microcontroller to do a variety of things from flashing an LED to driving a motor, etc. Today, we will see how to play notes of a song with a PIC microcontroller. Musical notes are simply sound waves of particular frequencies. If the frequency of a note is known correctly, a microcontroller can be programmed to play the note by generating a square wave (of the same frequency) signal at one of its I/O pins. The signal must be fed to a speaker to listen to the sound. Here, we will discuss playing notes of the popular “Happy birthday to you” tune using a PIC16F628A microcontroller and a buzzer.

Musical notes using a PIC micro

Read more

How to use mikroElektronika’s GLCD bitmap editor tool to convert a BMP image in to a data array

This tutorial describes how to use the mikroElektronika’s GLCD bitmap editor tool to convert a monochromatic bit map (BMP) image file into a data array so that it could be displayed on a graphics LCD using a microcontroller. The GLCD bitmap editor tool is embedded into mikroElektronika’s compilers. It can generate a code equivalent of a BMP image, which can be easily inserted into the microcontroller’s source program.

MikroElektronika's GLCD BMP editor

Read more

Lab 4: Interfacing a character LCD


HD44780 based LCD displays are very popular among hobbyists because they are cheap and they can display characters. Besides they are very easy to interface with microcontrollers and most of the present day high-level compilers have in-built library routines for them. Today, we will see how to interface an HD44780 based character LCD to a PIC16F688 microcontroller. The interface requires 6 I/O lines of the PIC16F688 microcontroller: 4 data lines and 2 control lines. A blinking test message, “Welcome to Embedded-Lab.com”, will be displayed on the LCD screen.

Required Theory

All HD44780 based character LCD displays are connected through 14 pins: 8 data pins (D0-D7), 3 control pins (RS, E, R/W), and three power lines (Vdd, Vss, Vee). Some LCDs have LED backlight feature that helps to read the data on the display during low illumination conditions. So they have two additional connections (LED+ and LED-), making altogether 16 pin. A 16-pin LCD module with its pin diagraam is shown below.

Read more

Lab 1: Flashing an LED


Today is our first session in PIC microcontroller lab, and we will begin with an experiment that flashes an LED on and off. While this looks very simple it is the best project to start because this makes sure that we successfully wrote the program, compiled it, loaded inside the PIC, and the circuit is correctly built on the breadboard.

In this lab session we will connect an LED to one of the port pin of PIC16F688 and flash it continuously with 1 sec duration.

Required Theory

You must be  familiarized with,

  • digital I/O ports (PORTA and PORTC) of PIC16F688
  • direction control registers, TRISA and TRISC
  • special function registers CMCON0 and ANSEL

If you are not then please read this first: Digital I/O Ports in PIC16F688.

Circuit Diagram

To our basic setup on the breadboard (read Getting Ready for the First Lab), we will add a light-emitting-diode (LED) to port pin RC0 (10) with a current limiting resistor (470 Ohm) in series. The complete circuit diagram is shown below.

Read more

Hardware and Software requirements

The development of an embedded system requires some hardware and software products. Although the hardware requirements depend on the type and complexity of the project, the following hardware tools are required in all of the experiments we are going to discuss here.

  1. A solderless breadboard for constructing and testing the experimental circuits. The breadboard is chosen because it is reusable. You can change, modify or remove the components on it at any time. While an embedded system is in development phase, you never know in advance whether or not your circuit will function correctly when assembled. So it is always good to test it first on a breadboard. Once it performs well, the circuit can be transferred to a printed circuit board.
  2. Microcontroller chips (PIC16F688 and PIC16F628A in this case)
  3. A PIC programmer to load firmware inside the microcontroller. You need to buy one with in circuit serial programming(ICSP) capability. This allows you to quickly program the PIC while it is in the target circuit. I have got an iCP01 USB PIC programmer from iCircuit Technologies. It is very handy, easy to use, and low-cost ICSP programmer for the most popular flash-based PIC microcontrollers. The best thing about it is that it is compatible with Microchip’s PICKit2 and MPLAB IDE softwares. And, it works great. Read Choosing a PIC Programmer.
  4. A PC is required for two purposes: to develop and compile the firmware for the microcontroller, and to transfer it to the PIC programmer so that it could be loaded into the program memory of the microconroller.
  5. A regulated +5V DC source to power your circuit on the breadboard.
  6. A digital multimeter as test equipment.
  7. Other components like resistors, LEDs, capacitors, wires, etc as required.

iCP01 USB PIC programmer that uses PICkit2 software for programming

Required Software Tools

In addition to the above hardware, following software products are required during the experiments.

  1. A Compiler to develop and compile the firmware. You need to download and install the free version of mikroC Pro for PIC (a C compiler for PIC from Mikroelektronika) to follow these experiments. Here is the download link: mikroC Pro for PIC. Also download mikroC Pro manual and Create First Project. These user’s manuals describe the compiler features and setup procedure in detail.
  2. A microcontroller device programmer software that’s provided by the vendor along with the programmer hardware. It is required to transfer the firmware from the PC to the microcontroller. You can download PICkit2 programming software for iCP01 USB PIC programmer here.
« Older Entries Recent Entries »