0

I've been working on some software to do REALLY basic composition of music. Here's my code so far:

#include "notes_sharps.h"
int notes[] = {NOTE_B0,NOTE_C1,NOTE_D1,NOTE_E1,NOTE_F1,NOTE_G1,NOTE_A1,NOTE_B1,NOTE_C2,NOTE_D2,NOTE_E2,NOTE_F2,NOTE_G2,NOTE_A2,NOTE_B2,NOTE_C3,NOTE_D3,NOTE_E3,NOTE_F3,NOTE_G3,NOTE_A3,NOTE_B3,NOTE_C4,NOTE_D4,NOTE_E4,NOTE_F4,NOTE_G4,NOTE_A4,NOTE_B4,NOTE_C5,NOTE_D5,NOTE_E5,NOTE_F5,NOTE_G5,NOTE_A5,NOTE_B5,NOTE_C6,NOTE_D6,NOTE_E6,NOTE_F6,NOTE_G6,NOTE_A6,NOTE_B6,NOTE_C7,NOTE_D7,NOTE_E7,NOTE_F7,NOTE_G7,NOTE_A7,NOTE_B7,NOTE_C8,NOTE_D8};
void setup(){
 Serial.begin(9600);
 for(int i = 0; i < 51; i++){
 Serial.println("%i's sharp is %i",notes[i], notes[i]+(notes[i]*0.05937)); 
 }
}
void loop(){}

This code just refuses to compile, no error messages, it simply leaves my computer dormant. Here's the log:

C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10604 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard C:\Users\anidude\AppData\Local\Temp\build38239327143584304.tmp\sharpscalc.cpp -o C:\Users\anidude\AppData\Local\Temp\build38239327143584304.tmp\sharpscalc.cpp.o

asked May 13, 2015 at 17:18
8
  • Are you able to upload other codes to that unit? Commented May 13, 2015 at 17:27
  • That's a new usage of Serial.println... I think you're mixing Serial.println(const char *) and sprintf(char *buf, const char *format, ...) Commented May 13, 2015 at 17:28
  • @Jasmine I can run the example toneMelody without error. Commented May 13, 2015 at 17:32
  • 1
    I tried it and I got a very clear error message: "fatal error: notes_sharps.h: No such file or directory". If I create the missing file, another error message, just as clear: "error: no matching function for call to ‘HardwareSerial::println(const char [17], int&, double)’". Commented May 13, 2015 at 17:39
  • here's the actual notes_sharps.h file pastebin.com/KVahvSNx Commented May 13, 2015 at 17:43

1 Answer 1

1

As Majenko stated in the comments, your use of the println function is not valid as there exists no overload that takes char*, int, int as parameters.

You could get your program to work by replacing your println as following:

for(int i = 0; i < 51; i++){
 Serial.print(notes[i]);
 Serial.print("'s sharp is ");
 Serial.println(notes[i]+(notes[i]*0.05937));
}
answered May 13, 2015 at 18:47

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.