https://www.electro-tech-online.com/custompdfs/2008/09/41291C.pdf
Code:
;Author Jake Wood
;Project Square Wave Keyboard
;Date 9 11 08
LIST p=16F884
include "P16F884.inc"
osccon 000; Oscillates at 31 kHz
bsf STATUS, RP0; to bank 1
movlw b'11111111' ;sets 255 to W
movfw TRISA ;all RA set to input
movfw TRISB ;all RB set to input
movlw b'11111110' ;sets 255 to W
movfw TRISC ;RC0-6 set to input RC7 to out
bcf STATUS, RP0 ;back to bank 0
cblock 0x20
timer
endc
buttons
movlw 0
movfw RC7 ;turn RC7 off
WaitForPress
btfss PORTA,b'00000001'; If RA0 is high, call tone <----- first btfss
movlw d'119' ;C
call tone}
If(RA1==1){
movlw d'112' ;C#
call tone}
If(RA2==1){
movlw d'106' ;D
call tone}
If(RA3==1){
movlw d'100' ;D#
call tone}
If(RA4==1){
movlw d'94' ;E
call tone}
If(RA5==1){
movlw d'89' ;F
call tone}
If(RA6==1){
movlw d'84' ;F#
call tone}
If(RA7==1){
movlw d'79' ;G
call tone}
If(RB0==1){
movlw d'75' ;G#
call tone}
If(RB1==1){
movlw d'70' ;A
call tone}
If(RB2==1){
movlw d'67' ;A#
call tone}
If(RB3==1){
movlw d'63' ;B
call tone}
If(RB4==1){
movlw d'59' ;C
call tone}
If(RB5==1){
movlw d'56' ;C#
call tone}
If(RB6==1){
movlw d'53' ;D
call tone}
If(RB7==1){
movlw d'50' ;D#
call tone}
If(RC0==1){
movlw d'47' ;E
call tone}
If(RC1==1){
movlw d'44' ;F
call tone}
If(RC2==1){
movlw d'42' ;F#
call tone}
If(RC3==1){
movlw d'40' ;G
call tone}
If(RC4==1){
movlw d'37' ;G#
call tone}
If(RC5==1){
movlw d'35' ;A
call tone}
If(RC6==1){
movlw d'33' ;A#
call tone}
}
tone:
while(*The Bit that got us here*== 1)
movlw 1
movfw TRISC7
*delay for time*
movlw 0
movfw TRISC7
*delay for time*
}
end
Last edited: