setint %00001000,%00001000 ;------ Variables ----- symbol Slot0 = b0 symbol Slot1 = b1 symbol Slot2 = b2 symbol Slot3 = b3 symbol Slot4 = b4 symbol Slot5 = b5 symbol Slot6 = b6 symbol Slot7 = b7 symbol BankNo = b8 symbol SlotPos = b9 symbol Note = b10 symbol i = b11 symbol Length = b12 symbol Rest = w6 ;uses b12,b13 ;----- Const ----- symbol Tempo = 100 ;sets length of on note ;----- Input Pin Assign ----- symbol Switch0 = pin0 ;triangle symbol Switch1 = pin1 ;square symbol Switch2 = pin2 ;circle symbol Switch3 = pin3 ;star ;--------------------- Main -------------------------- Main: ;high portc 7 gosub S0 ;loop through the 8 slots one at a time gosub S1 gosub S2 gosub S3 gosub S4 gosub S5 gosub S6 gosub S7 goto Main ;-------------------- this section checks what sounds is played with what slot --------------------------- S0: SlotPos = 0 let pins = SlotPos if Slot0 = 0 then gosub Bank0 if Slot0 = 1 then gosub Bank1 if Slot0 = 2 then gosub Bank2 if Slot0 = 3 then gosub Bank3 if Slot0 = 4 then gosub Bank4 ; pause Tempo return S1: SlotPos = 1 let pins = SlotPos if Slot1 = 0 then gosub Bank0 if Slot1 = 1 then gosub Bank1 if Slot1 = 2 then gosub Bank2 if Slot1 = 3 then gosub Bank3 if Slot1 = 4 then gosub Bank4 ; pause Tempo return S2: SlotPos = 2 let pins = SlotPos if Slot2 = 0 then gosub Bank0 if Slot2 = 1 then gosub Bank1 if Slot2 = 2 then gosub Bank2 if Slot2 = 3 then gosub Bank3 if Slot2 = 4 then gosub Bank4 ; pause Tempo return S3: SlotPos = 3 let pins = SlotPos if Slot3 = 0 then gosub Bank0 if Slot3 = 1 then gosub Bank1 if Slot3 = 2 then gosub Bank2 if Slot3 = 3 then gosub Bank3 if Slot3 = 4 then gosub Bank4 ; pause Tempo return S4: SlotPos = 4 let pins = SlotPos if Slot4 = 0 then gosub Bank0 if Slot4 = 1 then gosub Bank1 if Slot4 = 2 then gosub Bank2 if Slot4 = 3 then gosub Bank3 if Slot5 = 4 then gosub Bank4 ; pause Tempo return S5: SlotPos = 5 let pins = SlotPos if Slot5 = 0 then gosub Bank0 if Slot5 = 1 then gosub Bank1 if Slot5 = 2 then gosub Bank2 if Slot5 = 3 then gosub Bank3 if Slot5 = 4 then gosub Bank4 ; pause Tempo return S6: SlotPos = 6 let pins = SlotPos if Slot6 = 0 then gosub Bank0 if Slot6 = 1 then gosub Bank1 if Slot6 = 2 then gosub Bank2 if Slot6 = 3 then gosub Bank3 if Slot6 = 4 then gosub Bank4 ; pause Tempo return S7: SlotPos = 7 let pins = SlotPos if Slot7 = 0 then gosub Bank0 if Slot7 = 1 then gosub Bank1 if Slot7 = 2 then gosub Bank2 if Slot7 = 3 then gosub Bank3 if Slot7 = 4 then gosub Bank4 ; pause Tempo return ;----------------------- This section makes the 4 sounds, bank0 is the rest ----------------------------- Bank0: low portc 4 ;flash all leds for rest low portc 5 low portc 6 low portc 7 ;sound 7,(0,Tempo) ;This is the noise it make when it makes no noise Rest = Tempo * 10 pause Rest high portc 4 high portc 5 high portc 6 high portc 7 return Bank1: low portc 4 ;flash led that goes with shape Note = 1 ;Frequency Length = 3 'Note length for i = 1 to 10 ;let Note = Note + 10 'up in frequency sound 7,(Note,Length,50,Length) 'make sound next Length = Length * 10 ; calculation to get the rest value Length = Tempo - Length Rest = Length * 10 pause Rest ;sound 7,(0,Length) high portc 4 return Bank2: low portc 5 Note = 1 ;Frequency Length = 6 ;Note length for i = 1 to 10 let Note = Note + 70 'up in frequency sound 7,(Note,Length) 'make sound next Length = Length * 10 ; calculation to get the rest value Length = Tempo - Length Rest = Length * 10 pause Rest ;sound 7,(0,Length) high portc 5 return Bank3: low portc 6 Note = 40 ;Frequency Length = 6 ;Note length for i = 1 to 10 let Note = Note + 22 'up in frequency sound 7,(Note,Length) 'make sound next Length = Length * 10 ; calculation to get the rest value Length = Tempo - Length Rest = Length * 10 pause Rest ;sound 7,(0,Length) high portc 6 return Bank4: low portc 7 Note = 127 ;Frequency Length = 2 ;Note length for i = 1 to 10 let Note = Note - 5 'up in frequency sound 7,(Note,Length) 'make sound next Length = Length * 10 ; calculation to get the rest value Length = Tempo - Length Rest = Length * 10 pause Rest ;sound 7,(0,Length) high portc 7 return ;--------------- This interrupt assigns sounds to slot positions ---------------------- interrupt: if Switch0 = 1 and switch1 = 0 then : BankNo = 1 : endif ;checks to see which switch is pressed,, pin 0 not pin 1 if Switch1 = 1 and switch0 = 0 then : BankNo = 2 : endif ; pin 1 not pin 0 if Switch2 = 1 then : BankNo = 3 : endif ;just pin 2 if Switch0 = 1 and switch1 = 1 then : BankNo = 4 : endif ;switch 4 is a combo of pin 0 and 1 if SlotPos = 0 and Slot0 = BankNo then : BankNo=0 : endif ;This bit removes sound from a bank if the same sound button is pressed if SlotPos = 0 then : Slot0=BankNo : endif ;assigns bank number if SlotPos = 1 and Slot1 = BankNo then : BankNo=0 : endif if SlotPos = 1 then : Slot1=BankNo : endif if SlotPos = 2 and Slot2 = BankNo then : BankNo=0 : endif if SlotPos = 2 then : Slot2=BankNo : endif if SlotPos = 3 and Slot3 = BankNo then : BankNo=0 : endif if SlotPos = 3 then : Slot3=BankNo : endif if SlotPos = 4 and Slot4 = BankNo then : BankNo=0 : endif if SlotPos = 4 then : Slot4=BankNo : endif if SlotPos = 5 and Slot5 = BankNo then : BankNo=0 : endif if SlotPos = 5 then : Slot5=BankNo : endif if SlotPos = 6 and Slot6 = BankNo then : BankNo=0 : endif if SlotPos = 6 then : Slot6=BankNo : endif if SlotPos = 7 and Slot7 = BankNo then : BankNo=0 : endif if SlotPos = 7 then : Slot7=BankNo : endif pause 500 setint %00001000,%00001000 return