Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- { ; symbols - text strings to represent a value or pin
- symbol LED0 = 0
- symbol LED1 = 1
- symbol LED2 = 2
- symbol LED3 = 3
- symbol LED4 = 4
- symbol Buzzer = 5
- symbol cycle_counter = b1
- symbol cycle_counter2 = b2
- symbol random_value = b3
- symbol selected = b4
- symbol activated = b5
- symbol seed = b6
- symbol randopt = b7
- }
- let seed = 97 ; Prime number, good randomness
- main: ; A label, used with "goto [label]" to start executing code after the label
- { ; low all outputs (turn off)
- low LED1
- low LED2
- low LED3
- low LED4
- low LED0
- low Buzzer
- }
- let cycle_counter = 0 ; sets the counter to 0 (important so that "for ..." statements work for the right amount of time)
- let cycle_counter = 0
- 'for cycle_counter = 1 to 100
- 'pause 2000
- random random_value ; chooses a value from 0-255 and sets "random_value" to that value
- 'next
- let selected = random_value % 6 + 1
- if selected = 0 then
- high LED0
- elseif selected = 1 then
- high LED1
- elseif selected = 2 then
- high LED2
- elseif selected = 3 then
- high LED3
- elseif selected = 4 then
- high LED4
- endif
- ;if random_value < 52 then
- ; let selected = 0
- ; high LED0
- ;elseif random_value < 103 then
- ; let selected = 1
- ; high LED1
- ;elseif random_value < 154 then
- ; let selected = 2
- ; high LED2
- ;elseif random_value < 205 then
- ; let selected = 3
- ; high LED3
- ;elseif random_value <= 255 then
- ; let selected = 4
- ; high LED4
- ;endif
- for cycle_counter2 = 1 to 3
- for cycle_counter = 1 to 200
- let activated = 0
- if selected = 0 and input0 = 1 then
- activated = 1
- elseif selected = 1 and input1 = 1 then
- activated = 1
- elseif selected = 2 and input2 = 1 then
- activated = 1
- elseif selected = 3 and input3 = 1 then
- activated = 1
- elseif selected = 4 and input4 = 1 then
- activated = 1
- endif
- if activated = 1 then
- ; random number generator
- pause 2000
- let randopt = cycle_counter % 3
- if randopt = 0 then
- let randopt = 61
- elseif randopt = 1 then
- let randopt = 91
- elseif randopt = 2 then
- let randopt = 79
- endif
- let cycle_counter = cycle_counter + random_value
- let cycle_counter = cycle_counter * randopt
- let cycle_counter = cycle_counter * seed
- 'let cycle_counter = cycle_counter * seed
- let random_value = random_value + cycle_counter
- high Buzzer
- pause 500
- goto main
- endif
- pause 1
- next cycle_counter
- next cycle_counter2
- goto main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement