Question
i need a help in this code for playing musical note using pic16F877A ,, there is a small error which says the (( Error at
i need a help in this code for playing musical note using pic16F877A ,, there is a small error which says the ((Error at file ../main.c line 1 column 17: (141) can't open include file ""xc.h"": Invalid argument )). this is the code witch i entered
#include <"xc.h">
void Sound_Play(unsigned freq_in_hz, unsigned duration_ms); void Tone1() { Sound_Play(659, 250); // Frequency = 659Hz, duration = 250ms } void Tone2() { Sound_Play(698, 250); // Frequency = 698Hz, duration = 250ms } void Tone3() { Sound_Play(784, 250); // Frequency = 784Hz, duration = 250ms } void Melody() { // Plays the melody "Yellow house" Tone1(); Tone2(); Tone3(); Tone3(); Tone1(); Tone2(); Tone3(); Tone3(); Tone1(); Tone2(); Tone3(); Tone1(); Tone2(); Tone3(); Tone3(); Tone1(); Tone2(); Tone3(); Tone3(); Tone3(); Tone2(); Tone2(); Tone1(); } void ToneA() { Sound_Play( 880, 50); } void ToneC() { Sound_Play(1046, 50); } void ToneE() { Sound_Play(1318, 50); }
void Melody2() { unsigned short i; for (i = 9; i > 0; i--) { ToneA(); ToneC(); ToneE(); } }
void main() {
TRISB = 0xF8; // Configure RB7..RB3 as input
Sound_Init(&PORTC, 3); Sound_Play(880, 1000); // Play sound at 880Hz for 1 second
while (1) { if (Button(&PORTB,7,1,1)) // RB7 plays Tone1 Tone1(); while (RB7_bit) ; // Wait for button to be released
if (Button(&PORTB,6,1,1)) // RB6 plays Tone2 Tone2(); while (RB6_bit) ; // Wait for button to be released
if (Button(&PORTB,5,1,1)) // RB5 plays Tone3 Tone3(); while (RB5_bit) ; // Wait for button to be released
if (Button(&PORTB,4,1,1)) // RB4 plays Melody2 Melody2(); while (RB4_bit) ; // Wait for button to be released
if (Button(&PORTB,3,1,1)) // RB3 plays Melody Melody(); while (RB3_bit) ; // Wait for button to be released } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started