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

8

Program examples

New instructions used in this chapter:

• INCF

• INCFSZ

• DECF

• ADDWF

Counting events

Counting of course is a useful feature for any control circuit. We may wish to count the number of times a door has opened or closed, or count a number of pulses from a rotating disc. If we count cars into a car park we would increment a file count every time a car entered, using the instruction INCF COUNT. If we needed to know how many cars were in the car park we would have course have to reduce the count by one every time a car left. We would do this by DECF COUNT. To clear the user file COUNT to start we would CLRF COUNT. In this way the file count would store the number of cars in the car park. If you prefer COUNT could be called CARS. ...

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