' Robotics with the Boe-Bot - HighVsPwmInRctime.bs2 ' Two decay measurements in a row. The first uses the HIGH, PAUSE, RCTIME ' approach, and the second charges the capacitor to 2.5 V with PWM before ' RCTIME. ' {$STAMP BS2} ' Target module = BASIC Stamp 2 ' {$PBASIC 2.5} ' Language = PBASIC 2.5 tRight1 VAR Word ' First right sensor decay time tRight2 VAR Word ' Second right sensor decay time PAUSE 1000 ' Wait 1 s before any DEBUG DO ' Main loop HIGH 3 ' 1 Set P3 high to start charging PAUSE 1 ' 2 Wait for cap to charge RCTIME 3, 1, tRight1 ' 3 P3->input, measure decay time PAUSE 1 ' Separate measurements by 1 ms PWM 3, 128, 1 ' Charge P3 cap to 2.5 V RCTIME 3, 1,tRight2 ' P3->input, measure decay time DEBUG HOME, "tRight1 = ", DEC5 tright1, ' Display results CR, "tRight2 = ", DEC5 tRight2 PAUSE 100 ' Wait 0.1 seconds LOOP ' Repeat main loop