main:
high b.3
pause 1000
pwmout b.3, 255, 200
for b0 = 85 to 130
sound c.1, (b0,2)
next b0
for b0 = 85 to 130
sound c.1,(b0,2)
next b0
pause 1000
for b0 = 80 to 125 step 1
sound c.1,(b0,2)
next b0
for b1 = 125 to 80 step -1
sound c.1,(b1,1)
next b1
pause 1000
for b0 = 90 to 125 step 1
sound c.1,(b0,3)
next b0
for b1 = 120 to 90 step -1
sound c.1,(b1,2)
next b1
pause 5000
pwmout b.3,255,0
low b.3
pause 8000
goto main
Our final working piece of written code! This combines commands to make the speaker work alongside the motor. The motor begins and the speaker follows with its series of sounds. When the speaker stops the motor continues to run for a further 5 seconds. There is an 8 second pause where everything is silent and not moving before the sequence begins again.
No comments:
Post a Comment