Can't verify

I am trying to verify this Sketch :New_midi_lyre_001 and I get this message:'flashLED' was not declared in this scope. Would be thankful if sombody could help me
here is the sketch:

/*********************************************************
This is a library for the MPR121 12-channel Capacitive touch sensor

Designed specifically to work with the MPR121 Breakout in the Adafruit shop
----> https://www.adafruit.com/products/

These sensors use I2C communicate, at least 2 pins are required
to interface

Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!

Written by Limor Fried/Ladyada for Adafruit Industries.
BSD license, all text above must be included in any redistribution
**********************************************************/

/*********************************************************
This code is derived by Jim Arlow from MPR121test.ino by Limor Fried/Ladyada.

Designed for use with an Arduino Uno connected to an
Adafruit MPR121 12-Key Capacitive Touch Sensor Breakout.

Written by Jim Arlow in 2018 for www.clearviewtraining.com
BSD license, all text above must be included in any redistribution.
**********************************************************/

#include <Wire.h>
#include "Adafruit_MPR121.h"

// You can have up to 4 on one i2c bus but one is enough for testing!
Adafruit_MPR121 cap = Adafruit_MPR121();

// Keeps track of the last strings touched so we know when strings are 'released'
uint16_t lasttouched = 0;
uint16_t currtouched = 0;

// Semitone offsets for major scale. First string is G.
// G A B C D E F G A B C D E F G A B C ...
int majorScaleOffsets[] = {-5, -3, -1, 0, 2, 4, 5, 7, 9, 11, 12, 14, 16, 17, 19, 21, 23, 24, 26};
int octave = 5;
int tonic = 0;

void setup() {
Serial.begin(31250); // Set MIDI baud rate for TX0

// Initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);

// The octave up and down buttons
// Initialize pins 2 and 3 as inputs.
// These are the only Uno pins that can accept external interrupts.
pinMode(2, INPUT_PULLUP); // Interrupt 0
pinMode(3, INPUT_PULLUP); // Interrput 1
// Attach external interrupts to pins 2 and 3.
attachInterrupt(digitalPinToInterrupt(2), octaveUp, FALLING);
attachInterrupt(digitalPinToInterrupt(3), octaveDown, FALLING);

// Flash continuously to indicate an error
while (!cap.begin(0x5A)) { flashLED(); }

// Flash 20 times to indicate success and to give the sensor time to stabilize
for (int i=0;i<20;i++){ flashLED(); }
}

void loop() {
negativeEdge();
}

void positiveEdge(){
// Get the currently touched strings
currtouched = cap.touched();

for (uint8_t i=0; i<12; i++) {
// if string i was not touched and is now touched, damp the note
if ((currtouched & _BV(i)) && !(lasttouched & _BV(i)) ) {
noteOff(octaveNumber() + majorScaleOffsets*);*

  • }*

  • }*

  • // Reset our state*

  • lasttouched = currtouched; *
    }
    void negativeEdge(){

  • // Get the currently touched strings*

  • currtouched = cap.touched();*

  • for (uint8_t i=0; i<12; i++) {*

  • // if string i was touched and is now released, play the note*

  • if (!(currtouched & BV(i)) && (lasttouched & BV(i)) ) {*
    _ noteOn(octaveNumber() + majorScaleOffsets + tonic);

    * }*
    * }*
    * // Reset our state*
    * lasttouched = currtouched; *
    }
    // Calculate the octave as a MIDI number
    int octaveNumber(){
    return octave * 12;
    }
    // Increase the octave
    int octaveUp(){
    * flashLED();*
    * octave = octave + 1;*
    * if (octave > 8) {octave = 8;}*
    }
    // Decrease the octave
    int octaveDown(){
    * flashLED();*
    * octave = octave - 1;*
    * if (octave < 1) {octave = 1;}*
    }
    // Plays a MIDI note on channel 1 with default velocity of 127
    void noteOn(int note, int velocity=127){
    * Serial.write(0x90);*
    * Serial.write(note);*
    * Serial.write(velocity);*
    }
    // Not used for the MIDI Lyre
    void noteOff(int note){
    * Serial.write(0x80);*
    * Serial.write(note);*
    * Serial.write(0);*
    }
    // Flash the internal LED
    void flashLED(int d=100){
    * digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)*
    delay(d); // wait for d1000 seconds_
    digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW*

    _ delay(d); // wait for d1000 seconds_
    _
    }*_

look - there is a smiley in your code and it turns into italic after a while... may be that's the issue ?

or is that you did not read the rules pinned at the top of the forum ?

or might be an order of function definition issue.. who knows...

Looks like the IDE is having problems with the functions that have defaults. The function prototypes are not being generated. You can add your own:

#include "Adafruit_MPR121.h"

void flashLED(int d = 100);
void noteOn(int note, int velocity = 127);

Then you will have to remove the defaults in the actual declarations.

Or you could move the functions to above where they are used so prototypes are not needed.

1 Like

Thank you very much johnwasser it seems like you have solved the problem, it verifies and upload now.

MollArk:
Thank you very much johnwasser it seems like you have solved the problem, it verifies and upload now.

You have NOT solved the problem with the look and feel of your first post. Please everyone would appreciate if you were to follow the forum rules..