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 1636
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?
...
|
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...
|
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 & "','" &...
|
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...
|
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();
...
|
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,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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$) {
}
...
|
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...
|
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...
|
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...
|
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,...
|
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...
|
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,...
| |