Programming the PIC Microcontroller with MBasic

Programs

Now that we have a high level understanding of bar codes and wands, let's look at some code.

We'll start with an experiment can we use MBasic to read the wand, or are we forced to code time-critical elements in assembler?

We'll start with a simple approach, counting the number of transitions reported when scanning a bar code. A transition is either a low-to-high resulting from the wand going from a space to a bar, or the high-to-low that occurs when the wand passes from a bar to a space. We'll use an interrupt driven technique to count transitions. In Chapter 6, Programs 6-3 and 6-4, we used the interrupt on PortB change function to read a rotary encoder, while Chapter 10 covers interrupts generically. If the operation of MBasic's RBint function isn't clear to you, please review Chapters 6 and 10.

Program 25-1
        ;<a class="internaljump"> href="#ch25pro01">Program 25-1</a>        ;Count the number of transitions        ;when scan a bar code        ;Constants        ;----------        VideoIn        Con    B4        ;Variables        ;----------        NoEdges        Var ...

UNLIMITED FREE
ACCESS
TO THE WORLD'S BEST IDEAS

SUBMIT
Already a GlobalSpec user? Log in.

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.

Customize Your GlobalSpec Experience

Category: Barcode Scanners
Finish!
Privacy Policy

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.