O'Reilly logo

PIC in Practice, 2nd Edition by David W Smith

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

3

Introductory projects

New instructions used in this chapter:

• MOVLW

• MOVWF

• DECFSZ

Let's have a look at a few variations of flashing the LEDs on and off to develop our programming skills.

LED_Flasher2

Suppose we want to switch the LED on for 2 seconds and off for 1 second. Figure 2.1 shows the circuit diagram for this application. The code for this would be:

;Program starts now.

Image

NB. This code would be added to HEADER84.ASM into the section called, “Program starts now”.

To do this open MPLAB, then FILE – OPEN – HEADER84.ASM

Add the code and saveas LED_FLASHER2.ASM

The text would then be assembled by the MPLAB software and then blown into ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required