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 seed0 = b6
- symbol seed1 = b7
- symbol seed2 = b8
- symbol seed3 = b9
- symbol randcache = b10
- }
- let seed0 = 97 ; Prime number, good randomness
- let seed1 = 61
- let seed2 = 91
- let seed3 = 79
- 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_counter2 = 0
- random random_value ; chooses a value from 0-255 and sets "random_value" to that value
- let selected = random_value % 6 - 1 ; Modulo math to get selected LED
- if selected = 5 then
- goto main
- elseif selected = 255 then
- selected = 0
- endif
- 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
- 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
- ; shake it all about
- ; none of the below code means anything, the more confusing it is the more random the number it generates
- let randcache = cycle_counter % 3
- if randcache = 0 then
- let randcache = seed1
- elseif randcache = 1 then
- let randcache = seed2
- elseif randcache = 2 then
- let randcache = seed3
- endif
- let cycle_counter = cycle_counter + random_value
- let cycle_counter = cycle_counter * randcache
- let cycle_counter = cycle_counter * seed0
- let random_value = random_value + cycle_counter
- ; kinda random number comes out here
- high Buzzer
- pause 500
- goto main
- endif
- pause 10
- next cycle_counter
- next cycle_counter2
- goto main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement