'----------------------------------------------------------------
'                      DT006_1.BAS
'               (c) 2000-2003 MCS Electronics
' This example serves as a test for the DT006 SimmStick
' The DT006 is a new SimmStick motherboard with integrated
' low cost SPI programmer
' So it is ideal to get started quick
' Learn more about this at www.simmstick.com
'----------------------------------------------------------------
'We are using the 90S2313 in this example
'!!!!!! ONLY ONE MICRO MAY BE INSERTED AT THE SAME TIME !!!!!!!!!
$regfile = "2313def.dat"

'I use a 8 MHz XTAL
$crystal = 8000000


'$SIM is used for software simulation
'remark the line when you program the chip!!
$sim
'First we allocate memory for the variables]
Dim Idx As Byte , I As Byte

'Now configure PORTB to serve as an output
Config Portb = Output


Do
  Portb = 255                                                 'inverted logic is used so switch all LEDS off
  For Idx = 0 To 7                                            'for all bits
    Reset Portb.idx                                           'inerted logic so make the pin LOW

    'now we want to sample one button to look if it is pressed
    'configure the pin for INPUT mode
    Config Pinb.3 = Input
    If Pinb.3 = 0 Then                                        'if it is pressed it returns 0
       For I = 1 To 10                                        '10 times
         Toggle Portb                                         'invert PORT B
         Waitms 50                                            'wait 50 mSec
       Next
    End If
    Config Pinb.3 = Output                                    'make it an output again!
    Wait 1                                                    'want 1 sec
  Next
Loop                                                          'for ever

'Now all leds must go one one at the time
'When you push the button for some time
'The LEDS will flash !