Phone:(705) 671-2652
    Fax:(705) 671-6127
   Email: tom@ontrak.net
Home Products Programming Applications Custom Designs Ordering News
    
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.

 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

 
    
Contact Information
Address Telephone Electronic Mail
Ontrak Control Systems Inc.
764 Notre Dame Ave., Unit #1
Tel: (705) 671-2652 General Information Sales or Support
Sudbury,Ontario Fax:(705) 671-6127 tom@ontrak.net
CANADA P3A 2T2    
              
Next-Day shipping anywhere in Continental U.S. via Fed-Ex
Copyright © 2012 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