;#picaxe 20m2 setfreq m8 '---------------------------------- ' Ausgänge '---------------------------------- dirsB = %11111111 symbol TA = pinC.6 symbol PROGRAMM = b0 symbol EVENT = b1 symbol Z = b2 symbol HELL = b3 symbol EEADR = b10 ' nur intern genutzt '================================================= ' LETZTES PROGRAMM LADEN (EEPROM) '================================================= EEPROM 0,(0) read 0, PROGRAMM ' falls ungültig if PROGRAMM > 7 then PROGRAMM = 0 endif ' Ausgänge Startzustand high B.0 high B.1 high B.2 high B.3 high B.4 high B.5 high C.0 high C.1 high C.2 high C.3 main: gosub Taster select case PROGRAMM case 0 gosub Bahnhof case 1 gosub Lauflicht case 2 gosub RGB case 3 gosub Disco case 4 gosub Blaulicht case 5 gosub Strobe case 6 gosub Nacht case 7 gosub Party endselect goto main '================================================= 'Taster (gegen Masse) '================================================= Taster: EVENT = 0 if TA = 1 then return endif pause 30 if TA = 1 then return endif Z = 0 do pause 10 inc Z loop while TA = 0 and Z < 100 if Z > 80 then EVENT = 3 do loop while TA = 0 goto EventBearbeiten endif pause 250 if TA = 0 then EVENT = 2 do loop while TA = 0 else EVENT = 1 endif EventBearbeiten: select case EVENT case 1 inc PROGRAMM if PROGRAMM > 7 then PROGRAMM = 0 endif write 0, PROGRAMM ' EEPROM speichern case 2 if PROGRAMM = 0 then PROGRAMM = 7 else dec PROGRAMM endif write 0, PROGRAMM ' EEPROM speichern case 3 gosub AllesAus endselect return '================================================= 'Alles aus '================================================= AllesAus: high B.0 high B.1 high B.2 high B.3 high B.4 high B.5 high C.0 high C.1 high C.2 high C.3 do loop while TA = 1 do loop while TA = 0 return '================================================= '0 Bahnhof '================================================= Bahnhof: low B.3 low B.5 pause 100 high B.3 high B.5 pause 100 return '================================================= '1 Lauflicht '================================================= Lauflicht: low B.0 pause 80 high B.0 low B.1 pause 80 high B.1 low B.2 pause 80 high B.2 low B.3 pause 80 high B.3 low B.4 pause 80 high B.4 low B.5 pause 80 high B.5 return '================================================= '2 RGB '================================================= RGB: low C.2 high C.1 high C.0 pause 500 high C.2 low C.1 high C.0 pause 500 high C.2 high C.1 low C.0 pause 500 return '================================================= '3 Disco '================================================= Disco: random w5 if bit0=1 then low B.0 else high B.0 endif if bit1=1 then low B.1 else high B.1 endif if bit2=1 then low B.2 else high B.2 endif if bit3=1 then low B.3 else high B.3 endif if bit4=1 then low B.4 else high B.4 endif if bit5=1 then low B.5 else high B.5 endif if bit7 = 1 then low C.1 else high C.1 endif if bit6 = 1 then low C.0 else high C.0 endif pause 120 return '================================================= '4 Blaulicht '================================================= Blaulicht: low B.2 high C.0 pause 120 high B.2 low C.0 pause 120 return '================================================= '5 Strobe '================================================= Strobe: low B.4 low B.5 low C.3 pause 40 high B.4 high B.5 high C.3 pause 40 return '================================================= '6 Nachtbetrieb '================================================= Nacht: low B.3 high B.5 high B.0 high B.1 high B.2 pause 500 return '================================================= '7 Party '================================================= Party: low B.4 low B.5 low C.2 pause 100 high C.2 low C.1 pause 100 high C.1 low C.0 pause 100 high C.0 return ;Bahnhofdisco mit Waggon ; +---------------------------------------------------------------------------------------------------+ ; ; Hinten B.5 Pa Waggon ; Weis ; +--++--++--++----++--+++--+ ; | | ; ---------+++--------+++----------+++----+ | | | ; | | R G B | |; ; Green Rot | | ; b.2 b.0 | c.2 c.1 c.0 ; | ; + +--++--++--++----++--+++--+ ; + ; c.2 rot + ; #Spot ; Disco #weis ; # B.4 ; Schein R c.0 ; Green c.1 + werfer G c.2 ; + Tanz B c.3 ; + Fläche W ; ; Blau c.0 + ; + ; + ; b.2 b.1 6 b.0 ; Blau Green Rot ; | | ; ---------+++--------++++---------++++---+ rot ; La B.3 Pa C.3 ; Green ; Weis Pa B.1 ; +-------------------+ ; EisWagen ;La=Strassenlampe ;Pa=Scheinwerfer für Disco Weis seri_out pin19 ;Spot Blender +-------------------+ ; port b.0-------------b.7 ; +-------------------+ ; |PicAxe 20M2 | ; +-------------------+ ; port c.7-----------c.0 ; ; ; +-------------------------------------------------------------------------------------------------------+ ;picaxe 20m2 Bahnhofdisco ; ; +---v---+ ; +5V |1 20 | masse ; PD0 D1 rxd | | txd Serial out (DAC) Eiswagen ; ADC C.7 | | B.0 ; jn C.6 | | B.1 pwm ; Eiswagen hpwmA C.5 | | B.2 ; hpwmB C.4 | | B.3 La weis ; hpwmC/pwm C.3 | | B.4 hpwmD spot ; pwm C.2 | | B.5 i2c ; PD6 C.1 | | B.6 hserin ; hserout C.ß | | B.7 i2c ; +-------+ ; ;-------------------------------------------------------------------------------------------------