Я хочу сделать код, который будет воспроизводить музыку, и когда я нажму кнопку, музыка остановится, и светодиод включится. У меня есть эта ошибка: статус выхода 1 слишком мало аргументов для функции 'void playNote (char, int)'. Существует мой код:Почему у меня: Слишком мало аргументов в моем коде на arduino?
int buttonState = 0;
int speakerPin = 10;
int buttonPin= 7;
int frequency = 500;
int ledPin = 13;
int length = 17; // the number of notes
char notes[] = "gcefgcefgcefgcefga "; // a space represents a rest
int beats[] = {2,2,1,1,2,2,1,1,2,2,1,1,2,2,1,1};
int tempo = 250;
void setup() {
// put your setup code here, to run once:
pinMode(speakerPin, OUTPUT);
pinMode(ledPin, OUTPUT);
pinMode(buttonPin,INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
buttonState = digitalRead(buttonPin);
if (buttonState==HIGH){
digitalWrite(ledPin, HIGH);
noTone(speakerPin);
}else {
digitalWrite(ledPin, LOW);
digitalWrite(speakerPin,HIGH);
}}
void playTone(int tone, int duration) {
for (long i = 0; i < duration * 5000L; i += tone * 15) {
if (buttonState==LOW){
playNote();
digitalWrite(speakerPin, HIGH);
delayMicroseconds(tone);
digitalWrite(speakerPin, LOW);
delayMicroseconds(tone);
}
}
}
void playNote(char note, int duration) {
char names[] = { 'c', 'd', 'e', 'f', 'g', 'a', 'b', 'C' };
int tones[] = { 1915, 1700, 1519, 1432, 1275, 1136, 1014, 956 };
for (int i = 0; i < 18; i++) {
if (names[i] == note) {
playTone(tones[i], duration);
}
}}
Приведенная ошибка не может быть более понятной. Что вы хотите, чтобы мы сказали? 'playNote' явно ожидает параметры' char' и 'int'. –