1 PRINT " BASIC PROGRAM USED TO DEMONSTRATE"
2 PRINT "THE COMMANDS USED TO CONTROL A ROBOT"


3 PRINT "DOS AND QBASIC CAN BE RUN BY A SINGLE "
4 PRINT "3.5 FLOPPY, OR 2 OLD, BLACK 5 .25 FLOPPIES"


5 CLS
6 PRINT
7 PRINT
8 PRINT "---------------------------------------"



9 PRINT " START OF PROGRAM "




10 PRINT
20 PRINT "TURNING ON THE PRINTER PORT "
21 PRINT
22 PRINT " 8 - BIT DATA PINS "
24 PRINT " AT ADDRESS &H 378 "
26 PRINT



30 PRINT " STEPPING THRU ALL 8 "
32 PRINT " OUTPUT PINS AT &H378"
34 PRINT
36 PRINT " THE 8 RED LIGHTS SHOW THE 8 BIT "
38 PRINT " NUMBER IN MEMORY LOCATION"
39 PRINT " &H378 "

40    OUT    &H378,    255

42 PRINT         " NOTE THAT 255 IS BINARY 1111 1111 AS THE"

44 PRINT         " COMPUTER SEES IT, OR, ALL 8 PINS ARE ON "

46 PRINT         " SO THAT ALL 8 LEDS ARE ON"

50 SLEEP 2

98 PRINT      " OUT &H378, 0 OUTPUTS A ZERO TO"

99 PRINT      " THE LOCATION 378, AND TURNS OFF ALL LIGHTS"

100 PRINT   "NOTE THAT ZERO ( 0 ) IS 0000 0000 "

101 PRINT    " IN BINARY , AS THE COMPUTER SEES IT"

103 PRINT    "SO THAT THE COMPUTER WOULD TURN"

105 PRINT    " ALL 8 PINS TO ZERO, OR OFF "

106 PRINT    "SO THAT ALL 8 LEDS ARE OFF"

110     OUT     &H378,     0

200 SLEEP 2
250     OUT     &H378,     1
251 PRINT
252 PRINT " NOTE THAT THE VALUE (1) IS THE LOCATION OF"
253 PRINT "BINARY DIGIT 1, WHICH WOULD BE 0000 0001 "
254 PRINT "WHICH IS THE FIRST LED OF THE 8 LEDS IN A ROW. "

255 SLEEP 1
256 OUT &H378, 0
257 SLEEP 1
260 OUT &H378, 2
261 PRINT
262 PRINT " NOTE THAT 2 IS THE BINARY VALUE 0000 0010 "
263 PRINT " SO THAT THE SECOND  LED NOW LIGHTS UP "
265 SLEEP 1
266 OUT &H378, 0
267 SLEEP 1

270 OUT &H378, 4
271 PRINT
272 PRINT  " NOTE THAT THE DECIMAL 4 IS BINARY 0000 0100 "
273 PRINT " SO THAT NOW THE 3RD LED IN THE ROW LIGHTS UP "
274 PRINT " SEE THE SECTION ON MATH AT KIDBOTS.COM FOR A"
275 PRINT  " DETAILED EXPLANATION OF DECIMAL AND BINARY MATH"
276 SLEEP 1
277 OUT &H378, 0
278 SLEEP 1

280 OUT &H378, 8
285 SLEEP 1

287 OUT &H378, 0
288 SLEEP 1


290 OUT &H378, 16
295 SLEEP 1
300 OUT &H378, 0
319 SLEEP 1

400 OUT &H378, 32
401 SLEEP 1

405 OUT &H378, 0
410 SLEEP 1

420 OUT &H378, 64
425 SLEEP 1
426 OUT &H378, 0
427 SLEEP 1

430 OUT &H378, 128
435 SLEEP 1

500 OUT &H378, 0
510 SLEEP 4
512 PRINT

519 PRINT " CLS MEANS CLEAR THE SCREEN"

520 CLS
530 PRINT
540 PRINT


550 PRINT " LOOKING AT INPUT 5 PINS "
551 PRINT
552 PRINT
554 PRINT " AT LOCATION &H 379 "
556 PRINT
560 PRINT
570 PRINT
580 PRINT " THE 8 GREEN LIGHTS SHOW THE "
582 PRINT " 8 BIT DATA AT MEMORY LOCATION"
584 PRINT " &H 379. THE FIRST 3 BITS ARE USUALLY"
586 PRINT " ALWAYS ON. 1+2+4 =7, SO THAT "
588 PRINT " THE VALUE STARTS AT 7 AND "
589 PRINT " GOES TO 255. TURN OFF ALL SWITCHES"
590 PRINT " TO CHECK VALUE OF  FIRST 3 BITS"
591 PRINT       " THE COMMAND  INP  READS THE VALUE "
592 PRINT       " FROM A MEMORY LOCATION AND PUTS"
593 PRINT       "  THE NUMBER IN A VARIABLE , X  "
600 PRINT
605               LET   X  =   INP   (&H379)
606 PRINT

610 PRINT "--- THE VALUE AT &H379 IS ...";   X
611 PRINT
612 PRINT " TYPICALLY YOU WOULD "
613 PRINT " SUBTRACT 7 TO FIND BINARY "
614 PRINT " PINS CONNECTED TO INPUT "
615 PRINT
616 PRINT    "THESE 5 BITS CAN BE CONNECTED TO"
617 PRINT    " 5 SWITCHES ON YOUR ROBOT"
618 PRINT    " THIS ALLOWS YOU TO INPUT DATA FROM
619 PRINT    "YOUR ROBOT   TO  THE  COMPUTER"
620 PRINT

629 PRINT " SLEEP (NUMBER) IS A PAUSE X SECONDS TIMER"
630 SLEEP 12

640 CLS
642 PRINT
644 PRINT


650 PRINT " TURNING ON 4 CONTROL PINS "
652 PRINT " AT LOCATION &H 37A "
653 PRINT

654 PRINT " (THE LAST 4 PINS ARE"
656 PRINT " ALWAYS OFF ) "
660 SLEEP 5
664 PRINT
670 PRINT " THE 8 YELLOW LIGHTS "
672 PRINT " ON MY DEMONSTRATION  BOARD, SHOW
674 PRINT " THE 8 BIT WORD AT 37A "

700 PRINT
710 PRINT "--- OUTPUTTING 15 AT &H37A "
711 PRINT
712 PRINT  " NOTE THAT THE DECIMAL VALUE 15 IS "
713 PRINT   " 0000 1111 IN BINARY, SO ALL 4 LEDS LIGHT "
712 PRINT
714 PRINT " ( ALL 4 LIGHTS ON )"
716 SLEEP 3

720      OUT     &H37A,    15
722 PRINT
730 SLEEP 4

740 PRINT "--- OUTPUTTING 0 AT &H37A "
742 PRINT
744 PRINT " ( ALL 4 LIGHTS OFF ) "
746 SLEEP 4
748 PRINT

750 OUT &H37A, 0
752 SLEEP 4

755 PRINT "--- OUTPUTTING 1, 2, 4, 8 AT &H37A "
756 PRINT

760 SLEEP 2
780 OUT &H37A, 1
785 SLEEP 2
790 OUT &H37A, 2
792 SLEEP 2
794 OUT &H37A, 4
796 SLEEP 2
800 OUT &H37A, 8
810 SLEEP 2
820 OUT &H37A, 0
830 SLEEP 3
840 PTINT " THESE VALUES REFLECT THAT THE "
850 PRINT" CHIPS ARE HARD WIRED TO NORMALIZE"
860 PRINT " ALL REVERSE LOGIC ON THE PORTS "
870 PRINT  " SO THAT 0 VOLTS =0 AND +5 VOLTS = 1 "
880 PRINT " AT ALL TIMES "
890 PRINT
892 PRINT
900 PRINT " END OF CONTROL LOOP"
910 PRINT
920 PRINT "---------------------------------------"
930 PRINT
940 PRINT "FOR  J = 1 TO ( A NUMBER ), NEXT J IS A LOOP"
941 PRINT " IF YOU PUT PROGRAM STEPS BETWEEN "
942 PRINT " FOR and NEXT, THEY REPEAT (NUMBER) OF TIMES"
943 PRINT " ON AN OLD SLOW 8086 OR 80186, JUST LOOPING"
944 PRINT " FROM FOR TO NEXT ACTS LIKE A TIMER DELAY"
945 PRINT " YOU CAN  CHANGE THE (NUMBER) TO ANY VALUE"

947        FOR  J = 1 TO 1234
948        NEXT  J

950 CLS


1000 GOTO 5
1100 PRINT " GO TO IS A BRANCH JUMP TO A STEP NUMBER"


__________________________________________________
TO PRINT The Basic CODE above, you would be best

to HIGHLIGHT ( DRAG THE MOUSE from the bottom, to the
TOP of the PAGE), then COPY ( CTRL C ) and then open
NOTEPAD (START, Programs, Accesories, Notepad), and
 
PASTE ( CTRL V ) the TEXT , only, into NOTEPAD, so that
you do not waste huge amounts of BLACK ink to print the
background. I chose this colour since it is similar to what you
would see on a typical 8086, 8088, 80186, 80188, etc. computer.
Once you have the TEXT in NOTEPAD, you can choose the
FONT and the SIZE to use less paper and ink.

If you CANNOT see the toolbar with the MENU on the LEFT
side of this page, using a home computer or laptop, or, if you
are on a CELL phone and cannot see or click on the menu at
the top of the screen, then you can, as an option, CLICK HERE
go to the correct HOME PAGE,    www.kidbots.com    
MATH                   CLICK HERE
HOW TO              CLICK HERE
TYPES                  CLICK HERE
ROBOT BASIC    CLICK HERE
IMAGES               CLICK HERE
Robot Cartoons      CLICK HERE
Robots                    CLICK HERE
About kidbots         CLICK HERE
______________________________
Kidbots.com is a Free website, with Free
information, on how to USE  Free computers
to make Free ROBOT controllers and
Free ROBOTS for kids.