Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ' {$STAMP BS2}
- ' {$PBASIC 2.5}
- KeyIn VAR Byte
- NoteOut VAR Word
- DEBUG "Use keys along number row to play sound", CR
- DEBUG "1=C, 2=C#, 3=D, 4=D#, 5=E ... '=' is B"
- Start:
- DEBUGIN KeyIn
- ' Accept "-" and "="
- IF KeyIn = 45 OR KeyIn = 61 THEN GOTO SetNote
- ' Also accept characters 0-9
- IF KeyIn > 57 OR KeyIn < 48 THEN GOTO Start
- SetNote:
- IF KeyIn = 49 THEN NoteOut = 2093 '\ C
- IF KeyIn = 50 THEN NoteOut = 2217 '| C#
- IF KeyIn = 51 THEN NoteOut = 2349 '| D
- IF KeyIn = 52 THEN NoteOut = 2489 '| D#
- IF KeyIn = 53 THEN NoteOut = 2637 '| - 1 to 9 E
- IF KeyIn = 54 THEN NoteOut = 2794 '| F
- IF KeyIn = 55 THEN NoteOut = 2960 '| F#
- IF KeyIn = 56 THEN NoteOut = 3136 '| G
- IF KeyIn = 57 THEN NoteOut = 3322 '/ Ab
- IF KeyIn = 48 THEN NoteOut = 3520 ' "0" A
- IF KeyIn = 45 THEN NoteOut = 3729 ' "-" Bb
- IF KeyIn = 61 THEN NoteOut = 3951 ' "=" B
- FREQOUT 4, 150, NoteOut ' Make sure speaker is connected on pin 4!
- GOTO Start
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement