programming the 8-pin microchip pic in basic volume 1 · pdf filemany of the products you...

Download Programming the 8-pin Microchip PIC in Basic Volume 1 · PDF filemany of the products you already are familiar with such as mp3 players, cell phones or video game players. A microcontroller

If you can't read please download the document

Upload: hanguyet

Post on 07-Feb-2018

216 views

Category:

Documents


0 download

TRANSCRIPT

  • Programming the 8-pin Microchip PIC in Basic

    Volume 1

    Using the PICBASIC PRO Compiler and PIC12F683

  • Table of ContentsCHAPTER 1 MICROCONTROLLER FUNDAMENTALS ...................... 7

    IN-CIRCUIT SERIAL PROGRAMMING ................................................................... 12 ICSP HARDWARE INTERFACE ............................................................................ 13 ICSP PIN-OUT .................................................................................................. 16 INSTALLING THE SOFTWARE ............................................................................... 17 INSTALLING MICROCODE STUDIO AND PICBASIC PRO ................................... 18 PICKIT2 SETUP ................................................................................................. 19

    CHAPTER 2 FLASH AN LED ..................................................................... 28

    HARDWARE ....................................................................................................... 29 SOFTWARE ........................................................................................................ 30 NEXT STEPS ...................................................................................................... 32 QUESTIONS ....................................................................................................... 34

    CHAPTER 3 LED TRAFFIC LIGHT ......................................................... 35

    HARDWARE ....................................................................................................... 35 SOFTWARE ........................................................................................................ 36 NEXT STEPS ...................................................................................................... 39 QUESTIONS ....................................................................................................... 40

    CHAPTER 4 SENSING A SWITCH ............................................................ 41

    HARDWARE ....................................................................................................... 42 SOFTWARE ........................................................................................................ 43 NEXT STEPS ...................................................................................................... 45 QUESTIONS ....................................................................................................... 46

    CHAPTER 5 - READ A POTENTIOMETER ............................................... 47

    HARDWARE ....................................................................................................... 48 NEXT STEPS ...................................................................................................... 53 QUESTIONS ....................................................................................................... 54

    CHAPTER 6 - SENSING LIGHT .................................................................... 55

    HARDWARE ....................................................................................................... 56 NEXT STEPS ...................................................................................................... 60 QUESTIONS ....................................................................................................... 61

    CHAPTER 7 CREATING SOUND .............................................................. 63

    HARDWARE ....................................................................................................... 64 SOFTWARE ........................................................................................................ 65

  • NEXT STEPS ...................................................................................................... 67 QUESTIONS ....................................................................................................... 68

    CHAPTER 8 SENSING VIBRATION ......................................................... 69

    HARDWARE ....................................................................................................... 70 SOFTWARE ........................................................................................................ 71 NEXT STEPS ...................................................................................................... 76 QUESTIONS ....................................................................................................... 77

    CONCLUSION .................................................................................................. 78

    APPENDIX A PROJECTS PARTS LIST .................................................... 80

    APPENDIX B ANSWERS TO QUESTIONS .............................................. 82

  • IntroductionI've been programming Microchip PIC microcontrollers for years. When I started programming the most common software option was assembly language programming which can be very confusing to the beginner. Then one day I discovered a product that advertised programming Microchip PIC microcontrollers in BASIC. It was the PICBASIC compiler from microEngineering Labs. They eventually released a more powerful version called PICBASIC PRO and I have been using that compiler ever since. Along the way they developed a sample version of the PICBASIC PRO compiler that is limited to a few parts and only 31 commands but it was more than enough for someone to try out this great method of programming for free.

    This book is a beginners guide to using the PICBASIC PRO and uses the sample version for all the projects. I will use a low cost programming kit from Microchip as the hardware so the reader can learn right along with me for little investment. This language is so powerful, the 31 commands dont seem like a limitation until you ge