473,386 Members | 1,754 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Can someone please help me I don't know how to fix this errors include definition is

Hi,
so, I am making a program which will flash different lights every time a different note is played (trying to play happy birthday). I keep getting the same errors and I have no idea how to fix them. Please help me.
This is my code:
Expand|Select|Wrap|Line Numbers
  1. int piezo = 8;
  2. int ledrood = 2;
  3. int ledgeel = 4;
  4. int ledgroen = 7;
  5. int ledblauw = 12;
  6. int ledwit = 13;
  7. int tweekeerlied = 50;
  8. char namen[] = {'A','B','C','D','E','F','G'};
  9. int tonen[] = {440, 493, 262, 294, 330, 349, 392};
  10. char noten[] = {"GGAGCBGGAGDCGGGECBAFFECDC"};
  11. int ritme[] = {3,2,2,2,2,4,3,2,2,2,2,3,2,2,2,2,2,2,3,2,2,2,2,4}; 
  12.  
  13. int tempo = 100;
  14.  
  15.  
  16. void setup() {
  17.   pinMode(piezo,OUTPUT);
  18.   pinMode(ledwit, OUTPUT);
  19.   pinMode(ledblauw, OUTPUT);
  20.   pinMode(ledgroen, OUTPUT);
  21.   pinMode(ledgeel, OUTPUT);
  22.   pinMode(ledrood, OUTPUT);
  23. }
  24.  
  25. void loop() {
  26.   int i, lengte;
  27.   for (i=0; i < tweekeerlied; i++)
  28.   {lengte = ritme[i] * tempo;
  29.    {if (noten[i] = ' ')
  30.   {delay = lengte;}
  31.    else {
  32.      tone(piezo, tonen(noten[i]), lengte);
  33.        if((tonen(noten[i]) = 392) || (tonen(noten[i]) = 440))
  34.        {digitalWrite(ledrood, HIGH);
  35.         delay(lengte);}
  36.      else if ((tonen(noten[i]) = 349) || (tonen(noten[i]) = 493))
  37.               {digitalWrite(ledgeel, HIGH);
  38.                delay(lengte);}
  39.               else if (tonen(noten[i]) = 330)
  40.               {digitalWrite(ledgroen, HIGH);
  41.                delay(lengte);}
  42.               else if ((tonen(noten[i]) = 294) || (tonen(noten[i]) = 440) || (tonen(noten[i]) = 493))
  43.               {digitalWrite(ledblauw, HIGH);
  44.                delay(lengte);}
  45.      else if (tonen(noten[i]) = 262)
  46.               {digitalWrite(ledwit, HIGH);
  47.                delay(lengte);};
  48.      }
  49.    }
  50.               digitalWrite(ledrood, LOW);
  51.               digitalWrite(ledgeel, LOW);
  52.               digitalWrite(ledgroen, LOW);
  53.               digitalWrite(ledblauw, LOW);
  54.               digitalWrite(ledwit, LOW);
  55.               delay(tempo/2);
  56.   }
  57.   while(true)
  58.               {noTone(piezo);
  59.                digitalWrite(ledrood, LOW);
  60.                digitalWrite(ledgeel, LOW);
  61.                digitalWrite(ledgroen, LOW);
  62.                digitalWrite(ledblauw, LOW);
  63.                digitalWrite(ledwit, LOW);
  64. }
  65.  
  66. {int ritme(char noten)
  67.               {int i;
  68.                int notenaantal = 7;
  69.                for(i=0;i<notenaantal;i++)
  70.                {if (namen[i] == noten)
  71.                {return(ritme[i]);}
  72.                 else {return(0)}
  73.                }
  74.               }
  75. }


And these are my errors:

Expand|Select|Wrap|Line Numbers
  1. In function 'void loop()':
  2.  
  3. 29:12: error: assignment of function 'void delay(long unsigned int)'
  4.  
  5.    {delay = lengte;}
  6.  
  7.             ^~~~~~
  8.  
  9. 29:12: error: cannot convert 'int' to 'void(long unsigned int)' in assignment
  10.  
  11. 31:32: error: 'tonen' cannot be used as a function
  12.  
  13.       tone(piezo, tonen(noten[i]), lengte);
  14.  
  15.                                 ^
  16.  
  17. 32:26: error: 'tonen' cannot be used as a function
  18.  
  19.         if((tonen(noten[i]) = 392) || (tonen(noten[i]) = 440))
  20.  
  21.                           ^
  22.  
  23. 32:53: error: 'tonen' cannot be used as a function
  24.  
  25.         if((tonen(noten[i]) = 392) || (tonen(noten[i]) = 440))
  26.  
  27.                                                      ^
  28.  
  29. 35:30: error: 'tonen' cannot be used as a function
  30.  
  31.       else if ((tonen(noten[i]) = 349) || (tonen(noten[i]) = 493))
  32.  
  33.                               ^
  34.  
  35. 35:57: error: 'tonen' cannot be used as a function
  36.  
  37.       else if ((tonen(noten[i]) = 349) || (tonen(noten[i]) = 493))
  38.  
  39.                                                          ^
  40.  
  41. 38:38: error: 'tonen' cannot be used as a function
  42.  
  43.                else if (tonen(noten[i]) = 330)
  44.  
  45.                                       ^
  46.  
  47. 41:39: error: 'tonen' cannot be used as a function
  48.  
  49.                else if ((tonen(noten[i]) = 294) || (tonen(noten[i]) = 440) || (tonen(noten[i]) = 493))
  50.  
  51.                                        ^
  52. 41:66: error: 'tonen' cannot be used as a function
  53.  
  54.                else if ((tonen(noten[i]) = 294) || (tonen(noten[i]) = 440) || (tonen(noten[i]) = 493))
  55.  
  56.                                                                   ^
  57. 41:93: error: 'tonen' cannot be used as a function
  58.  
  59.                else if ((tonen(noten[i]) = 294) || (tonen(noten[i]) = 440) || (tonen(noten[i]) = 493))
  60.  
  61.                                                                                              ^
  62.  
  63. 44:29: error: 'tonen' cannot be used as a function
  64.  
  65.       else if (tonen(noten[i]) = 262)
  66.  
  67.                              ^
  68. 66:15: error: a function-definition is not allowed here before '{' token
  69.  
  70.                {int i;
  71.  
  72.                ^
  73.  
  74. 74:1: error: expected '}' at end of input
  75.  
  76.  }
  77.  
  78.  ^
  79.  
  80. exit status 1
  81. assignment of function 'void delay(long unsigned int)'

Please help me. I would really appreciate it
Jan 24 '20 #1
1 1636
dev7060
636 Expert 512MB
29:12: error: assignment of function 'void delay(long unsigned int)'
Assigning something to a function?

29:12: error: cannot convert 'int' to 'void(long unsigned int)' in assignment
Comparison operator needs to be used instead of the assignment operator.

error: 'tonen' cannot be used as a function
"tonen" is an array.

66:15: error: a function-definition is not allowed here before '{' token
74:1: error: expected '}' at end of input
Watch out for the curly braces.
Jan 24 '20 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: shang | last post by:
Hi! I am trying to find a function that converts a string into a double or a long double number. I found atod() but I don't know which library I have to include to use it. Could someone help me? ...
1
by: hantuitm | last post by:
i need help to find errors in this program and improve its interface. #include <iostream> #include <string> int main() { string InputNumber; string words1,words2,words3,valCheck;
2
by: hojjatnikan | last post by:
please help me this code 62EH&5gx0wiqoQFw is this name ( Belux) but i dont know how convert it i dont know the algorithm of this code plead help me
3
by: james121285 | last post by:
I have written a program that will take the max and min of 10 set values. I have to now change my program to allow for these inputs to be entered in by another document, and print the values into...
4
by: Ron | last post by:
I am having a bit of problem with this code: Dim cmd As New OleDb.OleDbCommand("INSERT INTO help (Name, Email, telephone, description)VALUES('" & txtName.Text & "','" & txtEmail.Text & "','" &...
2
by: ichabod079 | last post by:
I'm new to C++ and I am struggling with the whole separate function thing and I am so frustrated right now it's not even funny. What i'm supposed to do is this code and I ask for the 1st number and...
30
by: Anarki | last post by:
The following is the program i am trying to compile //restrict.c #include <stdio.h> int main() { char arr = "Qualifiers" char * restrict p = arr; int i = 0; for(; i < 10; ++i)
2
by: sailormoon | last post by:
this information i put in data.txt 11221 MOHD IRFAN 80 70 11222 NURUL FITRAH 80 90 11223 MOHD FARHAN 70 80 11224 WAFFIN WARDAH 80 60 11225 SYAMSUL 50 50 99999 TAMAT 0 0 #include<fstream.h>
9
by: nilushika | last post by:
help to detect errors in this simple proggramme #include<stdio.h> #include<ctype.h> #include<string.h> struct customer readCustomer(); struct slot readSlot(); ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.