Higher Tech Studies -Prog Systems 3&4

Page 53

Programmable Systems Outcome 3 Activity Continued flash: for b2 = 1 to b1 high 7 pause 100 low 7 pause 100 next b2 return

' setup a for...next loop using b2 ' output pin on ' wait 100ms ' output pin off ' wait 100ms ' next loop ' return form sub-procedure

In this example the flash sub-procedure is used to actually flash the LED on and off. The number of times the LED flashes is set by variable b1, which is set before the sub-procedure is called. Therefore by changing the value of b1 the number of flashes can be changed. Note the end command between the main program and the sub-procedure. This is essential because it stops the Stamp Controller accidentally 'running into' the subprocedure after the main program has been completed.


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.