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.

Can anybody compile this for me?

Status
Not open for further replies.

jair_ie

New Member
I have this program in PicBasic. But I have not the program.
thanks a lot
'este es el programa de NACHO, controla la secuencia de acciones que ocurren en respuesta a los
'comandos verbales. tambien coordina los Infrarrojos.


rdy var porta.0
ird var porta.1
iri var porta.2
estop var porta.3
sen var porta.4
maskh var byte
maskl var byte
bird var bit
biri var bit
b2ird var bit
b2iri var bit
datos var portb
dir var byte
f var byte
badela var bit
b1 var bit
b2 var bit

f=25000
trisc=0
trisa=%00010001
trisb=%11111111
PR2=%11111111
T2CON=%00000111
ADCON1=%00000110

inicio: maskl=portb &%00001111 'cojo las unidades que salen del recono.
maskh=portb &%11110000 'ahora las decenas
if maskl=6 and maskh!=%01100000 then vaya 'miro si dijeron NACHO
if badela=1 then goto esquiv
gosub eli 'rutinas de IR
gosub eld
pause 10
goto inicio

eli: freqout iri,100,f 'emito por el IRi
if sen=0 then alto
return 'vuelvo a donde llamaron la rutina

eld: freqout ird,100,f
if sen=0 then alto
return

vaya: pause 200
maskh=portb &%11110000
if maskh=%01010000 then inicio
maskl=portb &%00001111
branch maskl,[inicio,izq,der,adela,atras,alto] 'escoge para donde ir
gosub eli
gosub eld
goto vaya

esquiv: freqout iri,100,f 'emito IR por izq
if sen=0 then
b1=1 'si el sensor es 0
goto der 'vaya derecha y b1=1
else
b1=0 'sino b1=0
endif
freqout ird,100,f 'emito por dere
if sen=0 then
b2=1 'si sensor=0 entonces b2=1
goto izq 'dele pa la iq\zquierda
else
b2=0 'si no b2=0
endif
goto inicio

alto: badela=0
estop=1
CCP1CON=%00000000
CCP2CON=%00000000
pause 200
goto inicio

adela: estop=0
CCP2CON=0
CCP1CON=0
CCPR2L=%00110101
CCP2CON=%00001100
pause 20
CCPR1L=%01111101
CCP1CON=%00001100
pause 200 'activo los servos, y prendo la rutina
badela=1 'de esquivar
goto vaya 'espero nueva direccion


atras: badela=0
estop=0
CCP2CON=0
CCP1CON=0
CCPR2L=%01111101
CCP2CON=%00001100
pause 20
CCPR1L=%00110101
CCP1CON=%00001100
pause 200
goto vaya

izq: badela=0
estop=0
CCP2CON=0
CCP1CON=0
CCPR1L=%01111101
CCP1CON=%00001100
pause 200
if b2=1 then 'miro si vengo de esquivar
freqout ird,100,f 'emito de nuevo
if sen=0 then 'si de nuevo hay obstaculo
goto izq 'le doy pa la izquierda
else
goto adela 'si no, pa lante
endif
endif
if b2=0 then goto vaya 'si no vengo de esquivar espero nueva orden

der: badela=0
estop=0
CCP2CON=0
CCP1CON=0
CCPR2L=%00110101
CCP2CON=%00001100
pause 200
if b1=1 then
freqout iri,100,f
if sen=0 then
goto der
else
goto adela
endif
endif
if b1=0 then goto vaya
end








it ends here thanks
 
What PIC are you using?
You can also do it at **broken link removed**
There is also a version of the PICbasic floating around in this forum :evil: :idea: :wink:
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top