Wednesday, January 26, 2011

The end for the fish

so all day yesterday we worked on our project
here's the code that i used: (in red is the code and in blue is the explanation)
main:
        readadc 4,b0                                      'get data from analog receiver"        if b0 > 210 then dying                          'if there is light live (do the codes for slow)        if b0 < 200 and b0 >160 then struggle  
'if the recieved number is
                                                                    between 160 and 200 do the codes for struggle if b0 < 160 then dead                                  'if the value of b0 is less than 160 do the codes for deadgoto main        'go back to main
dying:
 high 1       'fish heads move up
 high 2      'the fissh moth opens
 pause 1000      'wait 1 second
 low 1       'the head falls down
 low 2       'mouth closes
 pause 1000     
goto main

struggle:       'if the value of b0 is between 160 or 200
 high 1       'i make the motors to work faster
 high 2
 pause 90
 low 1
 low 2
 pause 90
goto main

dead:        'if the receiver does not receive enough light
 low 1       '- i shut down all the motors
 low 2
goto main

No comments:

Post a Comment