CTC 101 VU Meter

https://ctc101.arduino.cc/resources?id=32379590

me is not declared

What do I need to do to declare me? The code is not working.

You need to post the code here, because your link requires registration. Please read the forum instructions first, so you know how to use code tags for that.

1 Like

/*

  • VU-Meter
  • VU-Meter is a few LEDs grouped together into a line.
  • This library has some features that makes it easy to control
  • several LEDs. Functions to use are:
  • clear() - turns all LEDs off.
    
  • on(LEDindex) - turns one LED on
    
  • off(LEDindex) - turns one LED off
    
  • scrollRight(speed, startIndex) - one LED light up at a time from left to right
    
  • scrollLeft(speed, startIndex) - one LED light up at a time from right to left
    
  • blink(LEDindex,speed, times) - one LED blinks
    
  • blinkAll(speed, times) - all LEDs blink
    
  • fillFrom(startIndex, stopIndex) - turns LEDs from startIndex to stopIndex on
    
  • fill(numberOfLEDs) - turns LEDs on from first to numberOfLEDs 
    
  • (c) 2013-2016 Arduino LLC.
    */

#include <educationshield.h>

//Declare the VUMeter
VUMeter me;

//The pins used by the VUMeter, default to 2-5 and 7. Can be
//customized as wish, but do change the pinCount if the
//number of LEDs are changed.
int pins[]={2,3,4,5,7};

//How many pins are used. Should reflect the pins array above.
int pinCount=5;

void setup(){
//Configure the VU meter using parameters defined previously.
me.config(pinCount,pins);

//initialize the component. Must be called.
me.begin();

}
void loop(){
//fill(number)
// number: how many leds from first pin shall be turned on
//
//Fill 5 LEDs
me.fill(5);
delay(3000);

//clear()
//
//turn all the LEDs off
me.clear();
delay(1000);

//on(index)
// index: which LED being turned on
//
//Turn the 3rd LED on
me.on(2);
delay(1000);

//off(index)
// index: which LED being turned off
//
//Turn the 3rd LED off
me.off(2);
delay(1000);

//scrollRight(speed, startIndex)
// speed: milliseconds before the next LED turns on
// startIndex: from which LED to the left it start
// scrolling. If not specified, it's 1.
//
//One LED light up at a time, scroll from left to right
me.scrollRight(700);

//scrollLeft(speed, startIndex)
// speed: milliseconds before the next LED turns on
// startIndex: from which LED TO THE RIGHT it start
// scrolling. If not specified, it's 1.
//
//And then scroll back from the 2nd on the right
me.scrollLeft(700,1);

//blink(index, speed, times)
// index: which LED should blink
// speed: milliseconds, of which the LED light on and off
// times: how many times the LED blinks. Defaults to 1
//
//the 3rd led will be blinking for 10 times, each time
//with 100 milliseconds on and 100 milliseconds off
me.blink(2,100,10);

//blinkAll(speed, times)
// speed: milliseconds, of which all LEDs light on and off
// times: how many times the LED blinks. Defaults to 1
//
//All LEDs will be blinking 10 times
me.blinkAll(100,10);

//fillFrom(leftIndex,rightIndex)
// leftIndex: start filling from which LED
// rightIndex: end filling to which LED
//
//The 2nd to 4th LED will be light up
me.fillFrom(1,3);
delay(2000);

}</educationshield.h>

I did mention the code tags! Please follow the program and add them! I did forget to ask for the complete compile error listing, a 3 word quotation is not enough.

It says: 'VUMeter' does not name a type

Please read. I asked for the complete compiler error listing and code tags.

Arduino: 1.8.19 (Windows Store 1.8.57.0) (Windows 10), Board: "Arduino Uno"

sketch_feb14a:21:10: fatal error: educationshield.h: No such file or directory

#include <educationshield.h>

      ^~~~~~~~~~~~~~~~~~~

compilation terminated.

exit status 1

educationshield.h: No such file or directory

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

//When I delete educationshield.h, it says:

Arduino: 1.8.19 (Windows Store 1.8.57.0) (Windows 10), Board: "Arduino Uno"

sketch_feb14a:24:1: error: 'VUMeter' does not name a type

VUMeter me;

^~~~~~~

C:\Users\kristen_roecker1\Documents\Arduino\sketch_feb14a\sketch_feb14a.ino: In function 'void setup()':

sketch_feb14a:36:3: error: 'me' was not declared in this scope

me.config(pinCount,pins);

^~

C:\Users\kristen_roecker1\Documents\Arduino\sketch_feb14a\sketch_feb14a.ino: In function 'void loop()':

sketch_feb14a:47:3: error: 'me' was not declared in this scope

me.fill(5);

^~

C:\Users\kristen_roecker1\Documents\Arduino\sketch_feb14a\sketch_feb14a.ino: At global scope:

sketch_feb14a:110:2: error: expected unqualified-id before '<' token

}</educationshield.h>

^

exit status 1

'VUMeter' does not name a type

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

That's telling you that you are missing that library.
Crucial it is.
https://github.com/arduino-libraries/EducationShield/

Why do I need the library? Why can't I just run the code? How do I connect my code to the library? Why isn't this explained in CTC 101? What do I need to do?

Looks like the code is not running without

Because the library is needed

It is already is "connected" by #include <educationshield.h>

Ask the author of CTC101, or just skip that question.

Ask more meaningful questions; and read the answers of the others carefully.

Download the library from the link provided or use the arduino library manager and search for it (educationshield .h)

post edit --
adding pic

I think there is a "getting started with Arduino" on this site, it answers a lot of your questions.

There certainly is an explanation of how to ask questions! :roll_eyes:

A library is pre-written code so you don't have to write everything yourself or you don't have to write (or copy) the same code over-and-over. (It makes your code "look simpler".)

I don't know anything about that library but if you were making a VU meter library you might want to make a function that calculates dB and you could put that function in a library. Of course, when you call that function you program would need access to that library.

Thank you!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.