' ROULETTE WHEEL - PICAXE 20M2 (IC1) ' (roulette_20m2.bas) '---------------------------------------------------------------------------------- ' Electronic roulette wheel with 36 LEDs in a circle and operating in chaser mode. ' Optional LED37 (zero casino house number) is driven by a seperate output (pin12) ' Check Wikipedea for roulette wheel layouts or use table at end of this program. '.Below the LED wheel is a power switch, a piezo speaker and the play push button. ' Operation is simple - switch on - press play button - wait for the LEDs to stop. ' Next time - press the play button and the LEDs will now start at the stopped LED. ' Optional 18 LED version (fit JP1 link) - prize wheel for schools or sports clubs '---------------------------------------------------------------------------------- set_up:' ------------- initalise micro - start-up beep - set micro speed ----------- pause 100 let dirsC = %00111111: pinsC = %00111110 tune B.7,4,($27) setfreq m16 'goto xout_0 xout_0:'--------------- drive the X0 output - the loop sets the on-time ------------ high B.0 gosub xout_loop low B.0 'goto xout_1 xout_1:'--------------- drive the X1 output - the loop sets the on-time ------------ high B.1 gosub xout_loop low B.1 'goto xout_2 xout_2:'--------------- drive the X2 output - the loop sets the on-time ------------ high B.2 gosub xout_loop low B.2 'goto xout_3 xout_3:'--------------- drive the X3 output - the loop sets the on-time ------------ high B.3 gosub xout_loop low B.3 'goto xout_4 xout_4:'--------------- drive the X4 output - the loop sets the on-time ------------ high B.4 gosub xout_loop low B.4 'goto xout_5 xout_5:'--------------- drive the X5 output - the loop sets the on-time ------------ high B.5 gosub xout_loop low B.5 inc b4 'goto led_37 / goto zout_select led_37:'-------------- optionl casino house number driver - (see note 1) ---------- inc b5 if b5 < 6 then: goto zout_select: endif high B.6 gosub xout_loop low B.6 let b5 = 0 'goto zout_select zout_select:'--------- select next Zout pin after scanning the Xout pins ----------- pause 2 if pinC.6 = 1 and b4 = 3 then: let b4 = 0: endif if pinC.6 = 0 and b4 = 6 then: let b4 = 0: endif if b4 = 0 then: let pinsC = %00111110: endif if b4 = 1 then: let pinsC = %00111101: endif if b4 = 2 then: let pinsC = %00111011: endif if b4 = 3 then: let pinsC = %00110111: endif if b4 = 4 then: let pinsC = %00101111: endif if b4 = 5 then: let pinsC = %00011111: endif goto xout_0 xout_loop:'---------- click piezo - vary Xout on-time to set wheel speed ----------- pulsout B.7,200 readadc C.7,b1 b2 = 235 - b1 for b3 = 0 to b2 next b3 if b1 < 30 then gosub start_delay return start_delay:'--------- wait until start button charges the 47uF capacitor ---------- readadc C.7,b1 if b1 < 200 then goto start_delay return ' NOTE 1 optional LED37 code (zero) '----------------------------------------------------------------------------------- ' Remove these eight lines of code if LED37 is not fitted (details in main text) '----------------------------------------------------------------------------------- ' Definition of variables '----------------------------------------------------------------------------------- ' b1 = ADC input (pin3) is used to measure the 47uF capacitor voltage. ' b2 = derived from b1 and is a seed number in the b3 "for next loop". ' b3 = "for next loop" uses the b2 seed to set the xout pulse length. ' b4 = selects the next Zout pin - to enable the next group of LEDs. ' b5 = selects LED37 output(pin12) - after chaser drives 36 main LEDs. '----------------------------------------------------------------------------------- ' European style roulette wheel layout ' Actual LED numbers vrs.[red] and (black) wheel numbers '----------------------------------------------------------------------------------- ' 1[32] 2(15) 3[19] 4(4) 5[21] 6(2) 7[25] 8(17) 9[34] 10(6) 11[27] 12(13) ' 13[36] 14(11) 15[30] 16(8) 17[23] 18(10) 19[5] 20(24) 21[16] 22(33) 23[1] 24(20) ' 25[14] 26(31) 27[9] 28(22) 29[18] 30(29) 31[7] 32(28) 33[12] 34(35) 35[3] 36(26) '----------------------------------------------------------------------------------- ' LEDs are installed sequentialy 1 to 36 (or37) marked with the numbers in the table. ' Fit LED1 right of 12 o'clock and them step clockwise with LED36 left of 12 o'clock. ' Fit the optional LED37 (ie.zero on a green background) at the 12 o'clock position.