Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

program error

Status
Not open for further replies.

watzmann

New Member
Hi All ,

i have a problem with this program , i'm using proton picbasic .

my problem is this program is working well with motors but it doesn't take effect and stop when my sensors dectect something.

although i'm writing the program to check if there are anything in front of it and if not it continue , but if anything appears it should stop , but it doesn't ,

note : the ultrasonic signal is about 2.5 volts , is it enough?
i'm using ultrasonic detectors and pic 16f877

please read it and tell me what's wrong

Device = 16f877
XTAL = 4
ADCON1 =7

IF PORTC.3=1 THEN STOP ;check for the right sensor
IF PORTA.5=1 THEN STOP ;check for the left sensor

MAIN:
IF PORTC.3=1 THEN STOP ;check again
IF PORTA.5=1 THEN STOP ;check again

HIGH PORTB.5 ;go forward
HIGH PORTB.6 ;go forward

IF PORTC.3=1 THEN GOTO STOP ;check for the right sensor
IF PORTA.5=1 THEN GOTO STOP ;check for the left sensor

STOP:
LOW PORTB.5 ;stop the motors
LOW PORTB.6 ;stop the motors
DELAYMS 2000
HIGH PORTB.7 ;go reverse for 2 seconds
HIGH PORTB.4 ;go reverse for 2 seconds
DELAYMS 2000
LOW PORTB.5 ;stop
LOW PORTB.6

HIGH PORTB.5 ;turn for 1.5 second
HIGH PORTB.7 ;turn for 1.5 second
DELAYMS 1500
LOW PORTB.5 stop
LOW PORTB.7 stop
GOTO MAIN
 
Perhaps more details on which ultrasound sensors you're using would be nice. Also, have you tried the PICBASIC forums (**broken link removed**) in case your problem is a programming issue?
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top