Presentation is loading. Please wait.

Presentation is loading. Please wait.

Digital Electronics Board-of-Education : Input. Board of Education - Input This presentation will explain, both from a hardware and software perspective,

Similar presentations


Presentation on theme: "Digital Electronics Board-of-Education : Input. Board of Education - Input This presentation will explain, both from a hardware and software perspective,"— Presentation transcript:

1 Digital Electronics Board-of-Education : Input

2 Board of Education - Input This presentation will explain, both from a hardware and software perspective, how to properly connect simple input devices to the BOE. 2

3 Input / Output Pins on the BOE 3 The BOE has sixteen (16) pins that can be used for input or output. These pins are labeled P0 thru P15 and are connected to two headers on the BOE. Additionally, the headers have V dd (5 volts) and V ss (ground) connections.

4 Push-Button Switch 4 Normally Open Push-Button Switch Sometimes called a Tactile Switch Pins 1&4 and 2&3 are internally connected. When the button is pressed, the switch is closed. (right picture) When the button is NOT pressed, the switch is open. (left picture)

5 Example Switch Input 5 If the button is NOT PRESSED, P3 is pulled to a logic low (0 volts) through the 10KΩ + 220 Ω resistors. If the button is PRESSED, P3 is pulled to a logic high (5 volts) through the 220 Ω resistor.

6 Example Switch Input - Hardware 6 Switch Circuit

7 Example Switch Input - Software The IN command reads the logic level of the specified pin. Example : IN 3 Reads the logic level at P3 If the button is NOT PRESSED… IN 3 Will read a logic ‘0’. If the button is PRESSED… IN 3 Will read a logic ‘1’. 7 Switch Circuit

8 Example BASIC Program #1 New Commands: IN DEBUG 8 DO DEBUG ? IN3 PAUSE 500 LOOP END  Start of the DO/LOOP  Reads the status of P3, Displays the results  Pauses for 500 mSec (0.5 seconds)  End of the DO/LOOP  Ends the program Results Displayed in the Debug window 

9 Example BASIC Program #2 New Commands: IF/THEN/ELSE 9 DO IF (IN3=1) THEN HIGH 14 LOW 13 ELSE LOW 14 HIGH 13 ENDIF PAUSE 50 LOOP END  Start of the DO/LOOP  Reads the status of P3…. If it equals 1…  Turn P14 ON  Turn P13 OFF  Else…  Turn P14 OFF  Turn P13 ON  End of the IF/THEN/ELSE Command  Pause for 50 mSec  End of the DO/LOOP  Ends the program

10 Example BASIC Program #3 New Commands: DO / LOOP with Until 10  Start of the DO/LOOP  Execute command1 while in the loop  Continue DO/LOOP Until P3 = 1  Execute AFTER it leaves the loop  Ends the program DO command1 LOOP UNTIL IN3=1 Command2 END

11 Resources Parallax Inc. (2004). What’s A Microcontroller. –Retrieved July 15, 2009 –fttp://www.parallax.com/tabid/440/Default.aspx


Download ppt "Digital Electronics Board-of-Education : Input. Board of Education - Input This presentation will explain, both from a hardware and software perspective,"

Similar presentations


Ads by Google