# Error code in program of MIDI trigger

**URL:** <https://forum.arduino.cc/t/error-code-in-program-of-midi-trigger/491779>\
**Category:** Audio\
**Created:** [November 16, 2017, 8:58pm UTC](https://forum.arduino.cc/t/error-code-in-program-of-midi-trigger/491779 "2017-11-16T20:58:39Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chobbs](https://avatars.discourse-cdn.com/v4/letter/c/dc4da7/32.png) [@Chobbs](https://forum.arduino.cc/u/Chobbs)\
**Post date:** [November 16, 2017, 8:58pm UTC](https://forum.arduino.cc/t/error-code-in-program-of-midi-trigger/491779/1 "2017-11-16T20:58:39Z")

</div>

Hello,  
Noob here.  
I'm getting a error while programming for triggering a MIDI note to a electric piano.  
"error: 'noteOn' was not declared in this scope"

There are several of these.  
so I compared the other noteOn scripts.  
It seems to be the same except for changing the note.

Any ideas where to start looking.

Thank You,  
CVH

---

<div class="post-metadata">

**Author:** ![Grumpy\_Mike](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/grumpy_mike/32/213521_2.png) [@Grumpy\_Mike](https://forum.arduino.cc/u/Grumpy_Mike)\
**Post date:** [November 16, 2017, 9:03pm UTC](https://forum.arduino.cc/t/error-code-in-program-of-midi-trigger/491779/2 "2017-11-16T21:03:22Z")

</div>

> error: 'noteOn' was not declared in this scope"

That means you have not declared the noteOn function.

However I assume that you think you have so post your code ( in code tags please ) and we will see if we can spot what you have done wrong.

---

<div class="post-metadata">

**Author:** ![Chobbs](https://avatars.discourse-cdn.com/v4/letter/c/dc4da7/32.png) [@Chobbs](https://forum.arduino.cc/u/Chobbs)\
**Post date:** [November 16, 2017, 9:38pm UTC](https://forum.arduino.cc/t/error-code-in-program-of-midi-trigger/491779/3 "2017-11-16T21:38:57Z")

</div>

> Chobbs:  
> Hello,  
> Noob here.  
> I'm getting a error while programming for triggering a MIDI note to a electric piano.  
> "error: 'noteOn' was not declared in this scope"
> 
> There are several of these.  
> so I compared the other noteOn scripts.  
> It seems to be the same except for changing the note.
> 
> Any ideas where to start looking.
> 
> Thank You,  
> CVH

Using this code...  
Errors are here  
517:27: error:  
526:27: error:

Also, Code offered from [gist:7398948 · GitHub](https://gist.github.com/anonymous/7398948#file-gistfile1-cs-L1)

> > > > > > > > > > > > > > > > > >

digitalWrite(LaserPin, LOW);

digitalWrite(motorPin1, HIGH);  
digitalWrite(motorPin2, LOW);  
digitalWrite(motorPin3, LOW);  
digitalWrite(motorPin4, LOW);  
delay(delaymotor);

digitalWrite(LaserPin, HIGH); //This is beam 6  
delay(delaylaser);

if( (analogRead(0) \> sensor ) && (f == 0) )

{

digitalWrite(13, HIGH);  
noteOn(0x90, note6, 0x7F);  
f++;  
}

else if(analogRead(0) \< sensor )

{  
digitalWrite(13, LOW);  
noteOn(0x90, note6, 0x00);  
f = 0;  
}

digitalWrite(LaserPin, LOW);

digitalWrite(motorPin1, LOW);  
digitalWrite(motorPin2, LOW);  
digitalWrite(motorPin3, LOW);  
digitalWrite(motorPin4, HIGH);  
delay(delaymotor);

digitalWrite(LaserPin, HIGH); //This is beam 5  
delay(delaylaser);

if( (analogRead(0) \> sensor ) && (e == 0) )

{  
digitalWrite(13, HIGH);  
noteOn(0x90, note5, 0x7F);  
e++;  
}

else if(analogRead(0) \< sensor )

{  
digitalWrite(13, LOW);  
noteOn(0x90, note5, 0x00);  
e = 0;  
}

digitalWrite(LaserPin, LOW);

digitalWrite(motorPin1, LOW);  
digitalWrite(motorPin2, LOW);  
digitalWrite(motorPin3, HIGH);  
digitalWrite(motorPin4, LOW);  
delay(delaymotor);

digitalWrite(LaserPin, HIGH); //This is beam 4  
delay(delaylaser);

if( (analogRead(0) \> sensor ) && (d == 0) )

{  
digitalWrite(13, HIGH);  
noteOn(0x90, note4, 0x7F);  
d++;  
}

else if(analogRead(0) \< sensor )

{  
digitalWrite(13, LOW);  
noteOn(0x90, note4, 0x00);  
d = 0;  
}

digitalWrite(LaserPin, LOW);

digitalWrite(motorPin1, LOW);  
digitalWrite(motorPin2, HIGH);  
digitalWrite(motorPin3, LOW);  
digitalWrite(motorPin4, LOW);  
delay(delaymotor);

digitalWrite(LaserPin, HIGH); //This is beam 3  
delay(delaylaser);

if( (analogRead(0) \> sensor ) && (c == 0) )  
{  
digitalWrite(13, HIGH);  
noteOn(0x90, note3, 0x7F);  
c++;  
}

else if(analogRead(0) \< sensor )

{  
digitalWrite(13, LOW);  
noteOn(0x90, note3, 0x00);  
c = 0;  
}

digitalWrite(LaserPin, LOW);

digitalWrite(motorPin1, HIGH);  
digitalWrite(motorPin2, LOW);  
digitalWrite(motorPin3, LOW);  
digitalWrite(motorPin4, LOW);  
delay(delaymotor);

digitalWrite(LaserPin, HIGH); //This is beam 2  
delay(delaylaser);

if( (analogRead(0) \> sensor ) && (b == 0) )

{  
digitalWrite(13, HIGH);  
"517:27: error:" noteOn(0x90, note2, 0x7F);  
b++;  
}

else if(analogRead(0) \< sensor )

{  
digitalWrite(13, LOW);  
"526:27: error:" noteOn(0x90, note2, 0x00);  
b = 0;  
}

digitalWrite(LaserPin, LOW);

digitalWrite(motorPin1, LOW);  
digitalWrite(motorPin2, LOW);  
digitalWrite(motorPin3, LOW);  
digitalWrite(motorPin4, HIGH);  
delay(delaymotor);  
}

// Back to top.

---

<div class="post-metadata">

**Author:** ![Grumpy\_Mike](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/grumpy_mike/32/213521_2.png) [@Grumpy\_Mike](https://forum.arduino.cc/u/Grumpy_Mike)\
**Post date:** [November 16, 2017, 10:07pm UTC](https://forum.arduino.cc/t/error-code-in-program-of-midi-trigger/491779/4 "2017-11-16T22:07:39Z")

</div>

Hey I did say:-

> Grumpy\_Mike:  
> ( in code tags please )

Why are you ignoring me? Please read [How to use this forum](http://forum.arduino.cc/index.php/topic,148850.0.html)

And why have you not posted ALL the code.

We don't like going off site for the code.

I don't see anywhere you define the noteOn function so you will get an error message.

---

<div class="post-metadata">

**Author:** ![slipstick](https://avatars.discourse-cdn.com/v4/letter/s/50afbb/32.png) [@slipstick](https://forum.arduino.cc/u/slipstick)\
**Post date:** [November 16, 2017, 10:41pm UTC](https://forum.arduino.cc/t/error-code-in-program-of-midi-trigger/491779/5 "2017-11-16T22:41:23Z")

</div>

> Chobbs:  
> Any ideas where to start looking.

Yes. That isn't a complete program. You can tell because there's no setup() and no loop(). If you find the rest of the program it might compile.

Steve

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [May 6, 2021, 4:23am UTC](https://forum.arduino.cc/t/error-code-in-program-of-midi-trigger/491779/6 "2021-05-06T04:23:10Z")

</div>

Closed on May 6, 2021, 4:23am UTC


