Hi -hope this is the right area to post in anyway:
I've recently built the PIC buggy kit and I am trying tolearn through adapting the sample programme. I want to remove that beep you get when the buggy collides with something and add that annoying reversing beep you get with lorries when it actually reverses/
I know enough to be dangerous! So I thought gosub would work but how do I strip this subroutine intothe programme so that it only runs AT THE SAME TIME as the vehicle is reversing and turning? At the moment it just gets to the sub routine and then gets stuck.
If someone could point me in the right direction I would appreciate it. Thanks.
PS:I am having a problem receiving notifications of posts - I'll keepchecking but please be patient with me. Thank you.
I've recently built the PIC buggy kit and I am trying tolearn through adapting the sample programme. I want to remove that beep you get when the buggy collides with something and add that annoying reversing beep you get with lorries when it actually reverses/
Code:
led_loop:
let pins = %0000110 'let pins 1 and 2 go high turning both LEDs on
sound 0, (100,50) ' sets piezo tone and length
pause 50 ' pause
let pins = %00000000 'turn LEDs off
pause 50 'pause
goto led_loop
If someone could point me in the right direction I would appreciate it. Thanks.
Code:
'Buggy Test Program For PICAXE18 microcontroller
'using [URL="http://www.rev-ed.co.uk"]www.rev-ed.co.uk[/URL] Buggy Kit (CHI007 or MOD001)
'make sure piezo link LK3 is connected for sound to work on pin0!
'CPS May 2001
'output pin allocation (%76543210)
'76 = motor B
'54 = motor A
'3 = not used
'2 = LED B
'1 = LED A
'0 = piezo sounder
'input pin allocation (v1-4)
'1 = sensor B
'0 = sensor A
'input pin allocation (v5)
'2 = sensor B
'7 = sensor A
'start going forwards
'testing switches as you go
main:
let pins = %01010000
if pin2 = 1 then left
if pin7 = 1 then right
goto main
led_loop:
let pins = %0000110 'let pins 1 and 2 go high turning both LEDs on
sound 0, (100,50) ' sets piezo tone and length
pause 50 ' pause
let pins = %00000000 'turn LEDs off
pause 50 'pause
goto led_loop
'left switch hit
'so stop, light LED, beep, reverse, turn
left:
gosub led_loop
let pins =%10100000
pause 2000
let pins =%10010000
pause 1500
goto main
'right switch hit
'so stop, light LED, beep, reverse, turn other way
right:
gosub led_loop
let pins =%10100000
pause 2000
let pins =%01100000
pause 1500
goto main
Last edited by a moderator: