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: - int piezo = 8;
-
int ledrood = 2;
-
int ledgeel = 4;
-
int ledgroen = 7;
-
int ledblauw = 12;
-
int ledwit = 13;
-
int tweekeerlied = 50;
-
char namen[] = {'A','B','C','D','E','F','G'};
-
int tonen[] = {440, 493, 262, 294, 330, 349, 392};
-
char noten[] = {"GGAGCBGGAGDCGGGECBAFFECDC"};
-
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};
-
-
int tempo = 100;
-
-
-
void setup() {
-
pinMode(piezo,OUTPUT);
-
pinMode(ledwit, OUTPUT);
-
pinMode(ledblauw, OUTPUT);
-
pinMode(ledgroen, OUTPUT);
-
pinMode(ledgeel, OUTPUT);
-
pinMode(ledrood, OUTPUT);
-
}
-
-
void loop() {
-
int i, lengte;
-
for (i=0; i < tweekeerlied; i++)
-
{lengte = ritme[i] * tempo;
-
{if (noten[i] = ' ')
-
{delay = lengte;}
-
else {
-
tone(piezo, tonen(noten[i]), lengte);
-
if((tonen(noten[i]) = 392) || (tonen(noten[i]) = 440))
-
{digitalWrite(ledrood, HIGH);
-
delay(lengte);}
-
else if ((tonen(noten[i]) = 349) || (tonen(noten[i]) = 493))
-
{digitalWrite(ledgeel, HIGH);
-
delay(lengte);}
-
else if (tonen(noten[i]) = 330)
-
{digitalWrite(ledgroen, HIGH);
-
delay(lengte);}
-
else if ((tonen(noten[i]) = 294) || (tonen(noten[i]) = 440) || (tonen(noten[i]) = 493))
-
{digitalWrite(ledblauw, HIGH);
-
delay(lengte);}
-
else if (tonen(noten[i]) = 262)
-
{digitalWrite(ledwit, HIGH);
-
delay(lengte);};
-
}
-
}
-
digitalWrite(ledrood, LOW);
-
digitalWrite(ledgeel, LOW);
-
digitalWrite(ledgroen, LOW);
-
digitalWrite(ledblauw, LOW);
-
digitalWrite(ledwit, LOW);
-
delay(tempo/2);
-
}
-
while(true)
-
{noTone(piezo);
-
digitalWrite(ledrood, LOW);
-
digitalWrite(ledgeel, LOW);
-
digitalWrite(ledgroen, LOW);
-
digitalWrite(ledblauw, LOW);
-
digitalWrite(ledwit, LOW);
-
}
-
-
{int ritme(char noten)
-
{int i;
-
int notenaantal = 7;
-
for(i=0;i<notenaantal;i++)
-
{if (namen[i] == noten)
-
{return(ritme[i]);}
-
else {return(0)}
-
}
-
}
-
}
And these are my errors: - In function 'void loop()':
-
-
29:12: error: assignment of function 'void delay(long unsigned int)'
-
-
{delay = lengte;}
-
-
^~~~~~
-
-
29:12: error: cannot convert 'int' to 'void(long unsigned int)' in assignment
-
-
31:32: error: 'tonen' cannot be used as a function
-
-
tone(piezo, tonen(noten[i]), lengte);
-
-
^
-
-
32:26: error: 'tonen' cannot be used as a function
-
-
if((tonen(noten[i]) = 392) || (tonen(noten[i]) = 440))
-
-
^
-
-
32:53: error: 'tonen' cannot be used as a function
-
-
if((tonen(noten[i]) = 392) || (tonen(noten[i]) = 440))
-
-
^
-
-
35:30: error: 'tonen' cannot be used as a function
-
-
else if ((tonen(noten[i]) = 349) || (tonen(noten[i]) = 493))
-
-
^
-
-
35:57: error: 'tonen' cannot be used as a function
-
-
else if ((tonen(noten[i]) = 349) || (tonen(noten[i]) = 493))
-
-
^
-
-
38:38: error: 'tonen' cannot be used as a function
-
-
else if (tonen(noten[i]) = 330)
-
-
^
-
-
41:39: error: 'tonen' cannot be used as a function
-
-
else if ((tonen(noten[i]) = 294) || (tonen(noten[i]) = 440) || (tonen(noten[i]) = 493))
-
-
^
-
41:66: error: 'tonen' cannot be used as a function
-
-
else if ((tonen(noten[i]) = 294) || (tonen(noten[i]) = 440) || (tonen(noten[i]) = 493))
-
-
^
-
41:93: error: 'tonen' cannot be used as a function
-
-
else if ((tonen(noten[i]) = 294) || (tonen(noten[i]) = 440) || (tonen(noten[i]) = 493))
-
-
^
-
-
44:29: error: 'tonen' cannot be used as a function
-
-
else if (tonen(noten[i]) = 262)
-
-
^
-
66:15: error: a function-definition is not allowed here before '{' token
-
-
{int i;
-
-
^
-
-
74:1: error: expected '}' at end of input
-
-
}
-
-
^
-
-
exit status 1
-
assignment of function 'void delay(long unsigned int)'
Please help me. I would really appreciate it
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.
Sign in to post your reply or Sign up for a free account.
Similar topics |
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!
|
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;
|
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
|
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;
|
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...
| |
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:
...
|
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)
|
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>
|
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{
|
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...
|
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...
| |
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. ...
|
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |