'Random number generator by John Iovine 'Positive edged pulse on RB0 triggers interrupt. 'Positive pulse is provided by geiger counter reading background radiation 'Interupt handler reads stalled revolving number as random number 'Random number is displayed used colored LED's and outputted serially for computer access 'Process then repeats. 'PICBasic Pro Compiler 'What size random number do we want to generate ' Binary (heads or tails) ' RGB (four color LED's ' 1-10 (decimal) ' 1-255 (1 byte) ' 1- 65535 (2 bytes) DEFINE OSC 16 '16MHz Xtal TRISB = 1 'Set Register PORTB = 2 'Play LED lights in Pause 550 'sequence PORTB = 4 'upon start-up Pause 550 PORTB = 8 Pause 550 PORTB = 16 Pause 550 PORTB = 0 'variables b0 VAR BYTE w1 VAR WORD w2 VAR WORD w1 = 4 'set number range 0-3 OPTION_REG.6 = 1 ON INTERRUPT GoTo display INTCON = %10010000 Loop: For w2 = 1 TO w1 Next GoTo Loop display: Disable 'Disable further interrupts PORTB = 0 'Turn off LED Light SerOut PORTB.5,6, [w2.byte0, w2.byte1] 'Send random number to PC for Egg Pause 150 'Determine new LED Color IF w2 = 1 Then b0 = 2 'from random number IF w2 = 2 Then b0 = 4 IF w2 = 3 Then b0 = 8 IF w2 = 4 Then b0 = 16 PORTB = b0 'Output new LED Light Color INTCON.1 = 0 Resume Enable 'Enable interupts