473,549 Members | 2,734 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

1 New Member
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 1646
dev7060
639 Recognized Expert Contributor
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
11949
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? Thanks!
1
1240
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
2698
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
1368
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 another document. #include<stdio.h> int main () { int i; int a = { 10, -99, 888, 4, 234, 1, 30, 40, 22, 34 }; int max = a; int min = a;
4
1480
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 & "','" & txtTelephone.Text & "','" & txtDescription.Text & "')", New OleDb.OleDbConnection(strconn)) at the end, strconn is underlined in blue and says not...
2
1435
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 the 2nd number and then output the quotient and remainder. So I did the code and I fixed most of the errors and now I have 2 errors that say: ...
30
2236
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
2042
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
1459
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(); struct slot{int day,period;}; struct customer{
0
7524
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7451
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7720
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
6048
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5372
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3501
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3483
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1944
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1061
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.