Shop OBEX P1 Docs P2 Docs Learn Events
Piezo Tutorial - #define music notes fails — Parallax Forums

Piezo Tutorial - #define music notes fails

sdiguanasdiguana Posts: 11
edited 2014-01-07 11:48 in Learn with BlocklyProp
Im working through the piezo tutorial and was quite amused by the musical notes part of it. However, when i try the part on the bottom of the page which suggests to define the notes as variables, my code fails. what am i doing wrong?
Tutorial link: Here
Compiler Error:
Piezo.c: In function 'main': 
Piezo.c:20:15: error: expected expression before '=' token
Done. Build Failed!
/*   Piezo Beep.c  
   Beep a piezo speaker connected to P4.
 */
 #include "simpletools.h"                      // Include simpletools
 #define C6 = 1047
 #define D6 = 1175
 #define E6 = 1319
 #define F6 = 1397
 #define G6 = 11568
 #define A6 = 1760
 #define B6 = 1976
 #define C7 = 2093
                 
 int note[] = {C6, D6, E6};
 

 int main()                                    // main function             
 {
   for (int i = 0; i<(sizeof(note)/sizeof(int)); i++)
    {
     freqout(4, 500, note[i]);                     // pin, duration, frequency 
     pause(68); 
    }
   
 }

edit: Thanks twm .. the equals sign was the problem!

Comments

  • twm47099twm47099 Posts: 867
    edited 2014-01-07 11:48
    I think that there should not be the "=" in the #define statements.

    Tom
Sign In or Register to comment.