Среда разработки: microC PRO for PIC
Микроконтроллер: PIC16F887
Программатор: PICkit 3
Код программы:
void Tone1() { Sound_Play(659, 200); } void Tone2() { Sound_Play(698, 200); } void Tone3() { Sound_Play(784, 200); } void Melody() { Sound_Play(392,350);PORTD = 0b10101010;
Sound_Play(392,350);PORTD = 0b10101010;
Sound_Play(392,350);PORTD = 0b10101010; Sound_Play(311,250);PORTD = 0b10101010;
Sound_Play(466,100);PORTD = 0b10101010;
Sound_Play (392,350);PORTD = 0b10101010; Sound_Play(311,250);PORTD = 0b10101010;
Sound_Play(466,100);PORTD = 0b10101010;
Sound_Play (392,700);PORTD = 0b10101010; Sound_Play (587,350);PORTD = 0b10101010;
Sound_Play(587,350);PORTD = 0b10101010;
Sound_Play(587,350);PORTD = 0b10101010; Sound_Play(622,250);PORTD = 0b10101010;
Sound_Play(466,100);PORTD = 0b10101010;
Sound_Play(369,350);PORTD = 0b10101010; Sound_Play(311,250);PORTD = 0b10101010;
Sound_Play(466,100);PORTD = 0b10101010;
Sound_Play(392,700);PORTD = 0b10101010; Sound_Play(784,350);PORTD = 0b10101010;
Sound_Play(392,250);PORTD = 0b10101010;
Sound_Play (392,100);PORTD = 0b10101010; Sound_Play(784,350);PORTD = 0b10101010;
Sound_Play(739,250);PORTD = 0b10101010;
Sound_Play (698,100);PORTD = 0b10101010; Sound_Play(659,100);PORTD = 0b10101010;
Sound_Play (622,100);PORTD = 0b10101010;
Sound_Play (659,450);PORTD = 0b10101010; Sound_Play(415,150);PORTD = 0b10101010;
Sound_Play(554,350);PORTD = 0b10101010;
Sound_Play (523,250);PORTD = 0b10101010; Sound_Play(493,100);PORTD = 0b10101010;
Sound_Play(466,100);PORTD = 0b10101010;
Sound_Play (440,100);PORTD = 0b10101010; Sound_Play(466,450);PORTD = 0b10101010; Sound_Play(311,150);PORTD = 0b10101010;
Sound_Play (369,350);PORTD = 0b10101010;
Sound_Play (311,250);PORTD = 0b10101010; Sound_Play(466,100);PORTD = 0b10101010;
Sound_Play(392,750);PORTD = 0b10101010; } void main() { ANSEL = 0b00000011; ANSELH = 0x00; TRISD = 0b00000000; PORTD = 0; Sound_Init( & PORTA, 4);
do { Melody(); PORTD = 0b00000000; Delay_ms(3000); } while (1); }