Wardialer Rev1 code

'# wardialerrev1.bas  Rob stave
'# Basic picaxe code for a sound maker.
'# uses the picaxe08m and a 4094 to produce a
'# series of random 8 bit patterns in the form
'# xxxxyyyy  where xxxx and yyyy are three bits on
'# and one off.  For example 1110 1011
'# this pattern is feed into the NTE 1690 DTMF chip
'# to produce a sound.

'# The frequency is set by pin 4
'# Pin 3 sets a switch to determine if an alternating zero
'# should be sent to add more time between digits.
'# www.robthefiddler.com

symbol INPUT_PIN = 4
symbol DATA_PIN = 1
symbol CLOCK_PIN = 0
symbol STROBE_PIN = 2
' w0 = b0 and b1
symbol val = b0
symbol loopcount = b1
' w1
symbol RandomValue = w1

' w2 = b4 and b5
symbol delay = w2

' w3 = b6 and b7
symbol rand = b6

begin:
loopcount = 0;
low DATA_PIN
low CLOCK_PIN
low STROBE_PIN

setfreq m8
 readadc INPUT_PIN, w1

main:

      random w1

 '    b2 = b2 xor b3

     rand = b2 AND %00001111
     lookup rand, ($EE,$ED,$EB,$E7,$DE,$DD,$DB,$D7,$BE,$BD,$BB,$B7,$7E,$7D,$7B,$77 ), val

'#  val is b0 so just read the bits out
'#  and pulse the clock
    pin1 = bit7
    pulsout CLOCK_PIN, 50
    pin1 = bit6
    pulsout CLOCK_PIN, 50
    pin1 = bit5
    pulsout CLOCK_PIN, 50
    pin1 = bit4
    pulsout CLOCK_PIN, 50
    pin1 = bit3
    pulsout CLOCK_PIN, 50
    pin1 = bit2
    pulsout CLOCK_PIN, 50
    pin1 = bit1
    pulsout CLOCK_PIN, 50
    pin1 = bit0
    pulsout CLOCK_PIN, 50	

'#  pulse the stobe
    pulsout STROBE_PIN, 50

    readadc INPUT_PIN, delay
'#  wait a little bit
    delay = delay * 4
    pause delay

    if pin3 = 0 then
      gosub strobeAZero
    endif		

    goto main

strobeAZero:
    pin1 = 0
    pulsout CLOCK_PIN, 50
    pin1 = 0
    pulsout CLOCK_PIN, 50
    pin1 = 0
    pulsout CLOCK_PIN, 50
    pin1 = 0
    pulsout CLOCK_PIN, 50
    pin1 = 0
    pulsout CLOCK_PIN, 50
    pin1 = 0
    pulsout CLOCK_PIN, 50
    pin1 = 0
    pulsout CLOCK_PIN, 50
    pin1 = 0
    pulsout CLOCK_PIN, 50	

'#  pulse the stobe
    pulsout STROBE_PIN, 50

    pause delay

    return