Digital Electronics Board-of-Education : Output
Board of Education - Output This presentation will explain, both from a hardware and software perspective, how to properly connect simple output devices to the BOE. 2
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.
Example LED Output The LED circuit shown will be connected to the BOE using PIN 14 (P14). If P14 is set to a logic HIGH (5 volts), the LED will be on. If P14 is set to a logic LOW (0 volts), the LED will be off. 4
Example LED Output - Hardware 5 Note the polarity of the LED LED Circuit
Example LED Output - Software The HIGH command makes the specified pin an output and sets its value to a logic ‘1’ (5 volts) Example : HIGH 14 Will set P14 to a logic ‘1’ and turn the LED on. The LOW command makes the specified pin an output and sets its value to a logic ‘0’ (0 volts) Example : LOW 14 Will set P14 to a logic ‘0’ and turn the LED off. 6 LED Circuit
Example BASIC Program #1 New Commands: HIGH LOW PAUSE END 7 HIGH 14 PAUSE 500 LOW 14 PAUSE 1500 END Sets P14 to a logic ‘1’ and turns the LED on Pauses for 500 mSec (0.5 seconds) Sets P14 to a logic ‘0’ and turns the LED off Pauses for 1500 mSec (1.5 seconds) Ends the program – Required for all programs
Example BASIC Program #2 New Commands: GOTO 8 Label (not a command) Same Jumps to the GOTO label, in this case Main Same Main: HIGH 14 PAUSE 500 LOW 14 PAUSE 1500 GOTO Main END Repeats Forever
Example BASIC Program #3 New Commands: DO / LOOP 9 Start of the DO/LOOP Same End of the DO/LOOP Same DO HIGH 14 PAUSE 500 LOW 14 PAUSE 1500 LOOP END Repeats Forever
Example BASIC Program #4 New Commands: FOR / NEXT 10 Declares a byte variable called cnt Start of the FOR/NEXT loop Same End of the FOR/NEXT loop Same Repeats Ten Times cnt VAR Byte FOR cnt = 1 TO 10 HIGH 14 PAUSE 500 LOW 14 PAUSE 1500 NEXT END
Variable Types The previous example used a Byte variable. BASIC supports four data types: Note : Nib is short for Nibble 11 Variable TypeRange of Values Bit0 to 1 Nib0 to 15 Byte0 to 255 Word0 to 65535
Resources Parallax Inc. (2004). What’s A Microcontroller. –Retrieved July 15, 2009 –fttp://