



program electronique_orgue_008_16f628;
var
keydata, special, down: byte;
PS2_Data: sbit at RB6_bit;
PS2_Clock: sbit at RB7_bit;
PS2_Data_Direction: sbit at TRISB6_bit;
PS2_Clock_Direction: sbit at TRISB7_bit;
procedure Main_Init;
begin
CMCON := CMCON or $07; // disable comparators
TRISA := $00;
TRISB := $FF;
Ps2_Config; // Init PS/2 Keyboard
Delay_ms(100); // Wait for keyboard to finish
Sound_Init(PORTA, 0); // init sound port
Delay_ms(100); // Wait for sound init to finish
end;
begin
Main_Init;
while true do
begin
// données reçues du clavier PS/2 ?
if Ps2_Key_Read(keydata, special, down) then
begin
// touche standard reconnue ?
if (down <> 0) and (special = 0) and (keydata <> 0) then
begin
// émission de la note correspondant à la touche enfoncée
case keydata of
81 : Sound_Play(247, 100); // touche Q - Si2
83 : Sound_Play(262, 100); // touche S - Do3
69 : Sound_Play(277, 100); // touche E - Do#3
68 : Sound_Play(294, 100); // touche D - Re3
82 : Sound_Play(311, 100); // touche R - Re#3
70 : Sound_Play(330, 100); // touche F - Mi3
71 : Sound_Play(349, 100); // touche G - Fa3
89 : Sound_Play(370, 100); // touche Y - Fa#3
72 : Sound_Play(392, 100); // touche H - Sol3
85 : Sound_Play(415, 100); // touche U - Sol#3
74 : Sound_Play(440, 100); // touche J - La3
73 : Sound_Play(466, 100); // touche I - La#3
75 : Sound_Play(494, 100); // touche K - Si3
76 : Sound_Play(523, 100); // touche L - Do4
80 : Sound_Play(523, 100); // touche P - Do#4
77 : Sound_Play(523, 100); // touche M - Re4
end;
end;
end;
Delay_ms(10); // Debounce
end;
end.


