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

5

Using inputs

A control program usually requires more than turning outputs on and off. They switch on and off because an event has happened. This event is then connected to the input of the microcontroller to ‘tell’ it what to do next. The input could de derived from a switch or it could come from a sensor measuring temperature, light levels, soil moisture, air quality, fluid pressure, engine speed etc.

Analogue inputs are dealt with later, in this chapter we will concern ourselves with digital on/off inputs.

New instructions used in this chapter:

• BTFSC

• BTFSS

• CLRF

• MOVF

• SUBLW

• SUBWF

• RETLW

As an example let us design a circuit so that switch, SW1 will turn an LED on and off.

The circuit diagram is shown in Figure 5.1.

Figure 5.1 ...

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