Step 4:  Programming the IO

Clear previous program

Clear previous

To begin a new program, you should CLEAR the previous one.  You can do this with either the button or by typing clear.


A program that uses IO

For the ARMweb type the following program in the console window.

                             ' enable pin P0(7) is connected to the LED
WHILE X<30
  IO(7) = X AND 1       ' drive pin 7 high when x is odd, low when x is even
  X=X+1
  WAIT(500)
LOOP

For the DINkit type the following program in the console window.

                             ' enable pin P0(15) is connected to the LED
WHILE X<30
  IO(15) = X AND 1       ' drive pin 15 high when x is odd, low when x is even
  X=X+1
  WAIT(500)
LOOP

For the ARMweb and DINkit to drive the port 1 pins.  On all versions ARMweb and DINkit, you can use the following

   #include <LPC21xx.bas>

   FIO1DIR = FIO1DIR OR (1<<16)     ' enable the pin as an output
   WHILE X<30
       P1(16) = X and 1
       X=X+1
       WAIT(500)
    LOOP

Use the following if you have firmware 7.52 or later (includes floating point support)

                                 ' port 1 starts at 32
   WHILE X<30
       IO(32+16) = X and 1
       X=X+1
       WAIT(500)
    LOOP


Now RUN the program

The LED on the PCB should pulse 15 times.


And see the results

And see the results


Stop the program


Stop the program

To stop a running program simply press the Stop button.

On to Step 5