top01.jpg (17169 bytes)
mleft.jpg (4986 bytes) m01a.jpg (6169 bytes)     m02a.jpg (6905 bytes)     m03a.jpg (7743 bytes)    m04a.jpg (7456 bytes)     m05a.jpg (7878 bytes)     m06a.jpg (6862 bytes)     m07a.jpg (6076 bytes) mright01.jpg (5078 bytes)

Connecting Switches to Digital I/O Lines

To connect switches to digital I/O lines, only one additional component is required. Each digital input line used to read a switch must be tied to +5 volts with a 10Kohm resistor to avoid leaving the digital port floating when the switch is in the OPEN position. The switch is then connected between ground and the digital port. The program used to read the switches must first configure the digital I/O lines as input. This is done using the CPAxxxxxxxx command. To read the switch a RPAx command is used. The following BASIC program continually monitors the position of two switches using an ADR101 and updates their status on the screen.101sWEB.jpg (2923 bytes)

 switch1.gif (4885 bytes)

10 OPEN "COM1:9600,N,8,1,CS,DS,RS" AS#1
20 CLS
30 PRINT#1, "CPA11111111"
40 REM (FORCES CR)
50 PRINT#1, "RPA0"
60 INPUT#1, SWA
70 T1$="CLOSED" IF SWA=1 THEN T1$="OPEN"
80 PRINT#1, "RPA1"
90 INPUT#1, SWB
100 T2$="CLOSED" IF SWB=1 THEN T2$="OPEN"
110 LOCATE 1,1      
120 PRINT "SWITCH A IS "T1$
130 PRINT "SWITCH B IS "T2$
140 GOTO 50              

 Back to Applications Page

NEWS         PRODUCTS         PROGRAMMING          APPLICATIONS          CUSTOM DESIGN          ORDERING          HOME


TestPoint is a trademark of Capital Equipment Corp.   
LabVIEW is a trademark of National Instruments.
Visual BASIC is a trademark of Microsoft Corporation


Copyright © 1999 ONTRAK CONTROL SYSTEMS 764 Notre Dame Ave, Unit #1 , Sudbury, Ontario, CANADA P3A 2T2  
"Quality serial Data Acquisition Interfaces"           PH. (705) 671-2652 FAX (705) 671-6127