

program electronique_pic_tuto_base_son_001a;
procedure Init;
begin
CMCON := %00000111; // comparators OFF
TRISIO.0 := 0; // GPIO configuré en sortie
ANSEL.ANS0 := 0; // GPIO configuré en sortie numérique
end;
// main program
begin
Init;
while true do
begin
GPIO.0 := GPIO.0 xor 1; // changement d'état logique
Delay_us(500); // delai avant de changer d'état logique
end;
end.
program electronique_pic_tuto_base_son_001b;
var
i: byte;
procedure Init;
begin
CMCON := %00000111; // comparators OFF
TRISIO.0 := 0; // GPIO configuré en sortie
ANSEL.ANS0 := 0; // GPIO configuré en sortie numérique
end;
// main program
begin
Init;
i := 0;
while true do
begin
if i < 200 then
begin
inc(i);
GPIO.0 := GPIO.0 xor 1;
delay_us(500);
end;
end;
end.
program electronique_pic_tuto_base_son_001c;
procedure Init;
begin
CMCON := %00000111; // comparators OFF
TRISIO.0 := 0; // GPIO configuré en sortie
ANSEL.ANS0 := 0; // GPIO configuré en sortie numérique
Sound_Init(GPIO, 0); // Preparation du port GPIO.0 pour sortie sonore
end;
// main program
begin
Init;
Sound_Play(1000, 100); // production du bip
end.
program electronique_pic_tuto_base_son_001c;
procedure Init;
begin
CMCON := %00000111; // comparators OFF
TRISIO.0 := 0; // GPIO configuré en sortie
ANSEL.ANS0 := 0; // GPIO configuré en sortie numérique
Sound_Init(GPIO, 0); // Preparation du port GPIO.0 pour sortie sonore
end;
// main program
begin
Init;
//
// Do = 239; DoD = 253; Re = 268; ReD = 284; Mi = 301; Fa = 319;
// FaD = 338; Sol = 358; SolD = 379; La = 402; LaD = 426; Si = 451;
//
Sound_Play(239, 200);
Delay_ms(10);
Sound_Play(239, 200);
Delay_ms(10);
Sound_Play(239, 200);
Delay_ms(10);
Sound_Play(268, 200);
Delay_ms(10);
Sound_Play(301, 400);
Delay_ms(10);
Sound_Play(268, 400);
Delay_ms(10);
Sound_Play(239, 200);
Delay_ms(10);
Sound_Play(301, 200);
Delay_ms(10);
Sound_Play(268, 200);
Delay_ms(10);
Sound_Play(268, 200);
Delay_ms(10);
Sound_Play(239, 400);
Delay_ms(10);
end.
program electronique_pic_tuto_base_son_001d;
var
i, j, iDelay, iPeriod: integer;
procedure Init;
begin
CMCON := %00000111; // comparators OFF
TRISIO.0 := 0; // GPIO configuré en sortie
ANSEL.ANS0 := 0; // set as analog input
end;
// main program
begin
Init;
while true do
begin
for iDelay := 1 to 100 do
begin
for iPeriod := 0 to 5 do
begin
GPIO.0 := GPIO.0 xor 1;
for j := 0 to iDelay do
delay_us(1);
end;
end;
end;
end.