Another programming assignment I had to do using Turing, was to set up a program, which does unique things with 8 lights. Things such as, all lights on, then off, light up one by one ascending, and descending, light up by 2 ascending, and descending, light up randomly 8 times, then have all the lights on. Here is how my program turned out to be.
loop
parallelput(255) % All lights on delay (1000) parallelput (0) % All lights off delay (1000) for i: 0..7 % Alternating lights "on, off" increasing by one parallelput (2**i) delay (1000) end for delay (1000) for decreasing i: 7..0 % Alternating lights "on, off" decreasing by one parallelput (2**i) delay (1000) end for delay (1000) for i: 0..7 by 2 % Alternating lights "on, off" increasing by two parallelput (2**i) delay (1000) end for delay (1000) for decreasing i: 7..0 by 2 % Alternating lights "on, off" decreasing by two parallelput (2**i) delay (1000) |
end for
delay (1000) for i: 0..13 % Lights "on, off" in random motation randomize var random : int randint (random, 0, 13) parallelput (2 ** random) delay (1000) parallelput (0) delay (1000) end for parallelput (0) delay (1000) for i :0..7 % Increasing - Decreasing LED's simultaneously on-off parallelput (2**i+2**(7-i)) delay (1000) if i=3 then parallelput (0) delay (1000) end if end for end loop |