100 lines
2.0 KiB
Plaintext
100 lines
2.0 KiB
Plaintext
' ########### start ###########
|
|
' pic:PIC16F886
|
|
' ########### end ###########
|
|
|
|
; FILE: Mary had a little Lamb with a Table - 16F886.gcb
|
|
; DATE: 31.01.2015
|
|
; VERSION: 1.0a
|
|
; AUTHOR: Evan R. Venn based on works of Chuck Hellebuyck
|
|
;
|
|
; Description.
|
|
' A demonstration program for GCGB and GCB.
|
|
' This program plays 'Mary had a little lamb' on portc.2 connected to Piezo speaker.
|
|
' It plays once and stops until the momentary switch on portb.0 is pressed then it plays again.
|
|
'
|
|
|
|
; This file is part of the Great Cow Basic compiler.
|
|
;
|
|
; This demonstration code is distributed in the hope that it will be useful,
|
|
; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
; GNU General Public License for more details.
|
|
;
|
|
; ----- Configuration
|
|
#chip 16F886, 16
|
|
|
|
; ----- Define Hardware settings
|
|
DIR portb.0 in
|
|
|
|
; ----- Constants
|
|
#define SoundOut portc.2
|
|
|
|
|
|
; ----- Variables
|
|
'Requires word size to hold note frequencies
|
|
dim note as word
|
|
|
|
|
|
; ----- Main body of program commences here.
|
|
Do
|
|
for cnt = 1 to 32
|
|
readtable mary, cnt, note ' Read notes from table
|
|
tone note, 50 ' Play notes
|
|
next
|
|
|
|
hold:
|
|
If D8=1 Then goto hold 'play music when switch is pressed
|
|
|
|
Loop
|
|
|
|
Table MARY
|
|
554 'C#
|
|
494 'B
|
|
440 'A
|
|
494 'B
|
|
554 'C#
|
|
0 'SILENT
|
|
554 'C#
|
|
554 'C#
|
|
494 'B
|
|
0 'SILENT
|
|
494 'B
|
|
0 'SILENT
|
|
494 'B
|
|
554 'C#
|
|
659 'E
|
|
0 'SILENT
|
|
659 'E
|
|
554 'C#
|
|
494 'B
|
|
440 'A
|
|
494 'B
|
|
554 'C#
|
|
0 'SILENT
|
|
554 'C#
|
|
0 'SILENT
|
|
554 'C#
|
|
494 'B
|
|
0 'SILENT
|
|
494 'B
|
|
554 'C#
|
|
494 'B
|
|
440 'A
|
|
|
|
end table
|
|
|
|
|
|
'Tone.gcb
|
|
|
|
'440 ' A
|
|
'466 ' A#
|
|
'494 ' B
|
|
'523 ' C
|
|
'554 ' C#
|
|
'587 ' D
|
|
'622 ' D#
|
|
'659 ' E
|
|
'699 ' F
|
|
'740 ' F#
|
|
'784 ' G
|
|
'831 ' G# |