You are previewing PIC Projects and Applications using C.
O'Reilly logo
PIC Projects and Applications using C

Book Description

PIC Projects and Applications Using C details how to program the PIC microcontroller in the C language. The book takes a learn-by-doing approach, with applications covering topics such as inputs, outputs, keypads, alphanumeric displays, analogue-to-digital conversion, radio transmitters and receivers, data EEPROM, interrupts and timing. To aid debugging, the book provides a section detailing the use of the simulator and in-circuit debugger.

With this book you will learn:

  • How to program the PIC microcontroller in C
  • Techniques for using the simulator and debuggers to find faults on your code
  • The ins and outs of interfacing circuits, such as radio modules and liquid crystal displays
  • How to use the PIC on-board functions, such as interrupts and timing modules, and make analogue measurements


  • Relevant parts of the language are introduced and explained when required for those new to the subject
  • Core principles are introduced gradually for self-paced learning
  • Explains how and why a software program works, and how to alter and expand the code

Table of Contents

  1. Cover image
  2. Title page
  3. Table of Contents
  4. Copyright
  5. Preface
  6. Chapter 1: Introduction to the Microcontroller and C
  7. Chapter 2: First C Program
    1. MPLAB and MPLABX Installation
    2. A Brief Introduction to C for the Microcontroller
    3. Writing the Code Using MPLAB IDE
    4. Types of Errors
    5. Programming the Microcontroller
    6. Writing the Code Using MPLABX
    7. Creating a New Project
  8. Chapter 3: Using Eight Outputs
    1. Explanation of the Code
    2. Looping in a Program
    3. The Disco Code
    4. The Header Program
  9. Chapter 4: Inputs
    1. IF Statement
    2. If–Else
    3. Using Several Inputs
  10. Chapter 5: Keypad Scanning
    1. Four Digit Code
    2. Putting the Scan Routine in a Header File, dwsScan.h
  11. Chapter 6: Analogue to Digital Conversion
    1. Configuring the A/D Device
    2. ADCON0 A–D Control Register 0
    3. ADCON1 A–D Control Register 1
    4. ADCON2 A–D Control Register 2
    5. ADRESH and ADRESL: A/D Result Registers High and Low Byte
    6. The Thermistor
    7. Making an A/D Reading with the Thermistor
    8. The LM335 Temperature Sensing IC
    9. Operation of the LM335
    10. A/D Application
    11. Question
    12. Using Several A–D Inputs
    13. Solar Panel Heating System
    14. Microcontrollers with More A/D Inputs
    15. The PIC18(L)F43K22 28A/D Inputs
  12. Chapter 7: Alpha Numeric Display
    1. Configuring the Display
    2. Program LCD.C
    3. Using Header: dwsLCD.h
    4. Program LCDh.C
    5. Character Display Address
    6. Displaying Measurements
    7. Displaying Room Temperature
    8. RoomTemperature.C
  13. Chapter 8: Porting Code to Other Microcontrollers
    1. The Header Code
  14. Chapter 9: Timer/Counter Modules
    1. TMR0 Prescaler
    2. Timing an Event
    3. An Accurate 1 s Time Period
    4. An Accurate 1 min Delay
    5. 24 h Clock
    6. 30 min Delays and Longer
  15. Chapter 10: Interrupts
    1. Explanation of the Program RBinterrupt.C
    2. TMR0 Overflowing Interrupt
  16. Chapter 11: Fault Finding, Using the Simulator, and the In-Circuit Debugger
    1. The Simulator Using MPLAB
    2. Setting Breakpoints
    3. Stopwatch
    4. Further Information
  17. Chapter 12: Radio Transmitters and Receivers
    1. The Transmitter
    2. The Receiver
    3. Examples
  18. Chapter 13: EEPROM Data Memory
  19. Chapter 14: Projects
    1. Project 1: Countdown Timer
    2. Project 2: Chess Clock
    3. Project 3: Resistance Meter
    4. Project 4: Capacitance Meter
    5. Project 5: Voltmeter
  20. Chapter 15: C Extra
    1. Data Types
    2. Conditional Operators
  21. Appendix A: Data Sheets
  22. Appendix B: Useful Contacts
  23. Index