NAVIGATION | Main | Abstract | Code | Diagrams and Graphs | Images | Below is a partial copy of one of the programs used
for the microcontroller. The code is written in a modified form of the
BASIC language. |
' {$STAMP BS2} ' {$PBASIC 2.5} ' ------- P PINs ----------------------------- pMaxRecv PIN 15 pMaxClock PIN 14 pMaxPWM PIN 0 ' --------------- X Variables ----------------- xDist VAR Word xPulse VAR Word xX VAR Byte ' ============ Main loop ================ DO GOSUB Run GOSUB sSerial DEBUG CR, CR PAUSE 50 LOOP END ' ------------- Subs ------------------------ Run: DO HIGH pMaxClock PULSIN pMaxPWM, 1, xPulse LOW pMaxClock DEBUG ? xPulse, " " xPulse = xPulse/100 IF xPulse < 10 THEN Sound1 IF xPulse < 50 THEN Sound2 IF xPulse < 100 THEN Sound3 IF xPulse < 200 THEN Sound4 IF xPulse < 350 THEN Sound5 LOOP DEBUG CR RETURN sSerial: Sound1: Sound2: Sound3: Sound4: Sound5: |