programa

'Robot Fire Team

'Autores: Joana Castelo, Paula Guerreiro, Ricardo Alves e José Fonseca

'Escola Sec. Emidio Navarro - Almada

'Ano - 8C

'2004

symbol esq=pin5   'laranja

symbol ct=pin6    'azul

symbol dir=pin7   'amarelo

symbol x=b0

symbol n=b1

symbol erro=b2

symbol cor=b3

low 0

low 1

inicio:

      pot 4,30,cor                  'Acertar POT c/ ALT-P no verde

      if cor>170 then apitar

      if ct=1 AND esq=1 AND dir=1 then branco

      if dir=0 then recuar_dir

if esq=0 then recuar_esq

      if ct=0 then virar_dir

      if ct=1 then virar_esq

      if erro=1 then virar_esq

      if erro=2 then virar_dir

goto inicio

'*****************************

'Rotina Virar Esquerda

virar_esq:

      erro=1

      pulsout 0,120

      pulsout 1,130

goto inicio

'****************************

'Rotina Virar Direita

virar_dir:

      erro=2

      pulsout 0,125

      pulsout 1,160

goto inicio

'***************************

'Rotina Frente

frente:

      for x=0 to 10

      pulsout 0,120

      pulsout 1,150

      next x

goto inicio

'***************************

'Rotina Apitar

apitar:

      sound 3,(10,100,30,200)

      pause 200

      goto frente

'***************************

'Rotina Branco

branco:

      for x=1 to 3

      pulsout 0,120     'virar esquerda  

      pulsout 1,130

      next       

      goto inicio

'***************************

'Rotina Recuar_Virar Direita

recuar_dir:

      for x=0 to 50

      pulsout 0,150

      pulsout 1,150

      next

goto inicio

'Rotina Recuar_Virar Esquerda

recuar_esq:

         for x=0 to 50

         pulsout 0,110

         pulsout 1,120

         next

goto inicio