shiftPWM you may help me understand little more

hi you all people you may help me to understand little more, this is a small part of code that is controlling the VU meter. left vu meter has 7 ledS and right vu meter 7ledS. the tractor software it send command 12 and number from 0-7. in (0) sound is off . on (1) sound little Hight and so on, till number 7 that is to high. (red leds in dj mixers or in any vu metter)

when dj softwear send no 7 then all 7 leds are light) if dj softwear send no 6 then 6 light lit.

leds are connect to hc595 bit shifter.

i understand from the code that ( if (number == 12) { ) this is the command that Arduino is waiting for light the led.

i understand that if the number arduino it gets is >7 then all led WILL STAY off
and if the number is 1<7 then the first led will light. and 2<7 led number 2 will lit

thank you for your time all

switch (value_) {
        case 0:
          for (int i = 0; i < 7; i++) {
            ShiftPWM.SetOne(VuL[i], LOW);
          }
          break;
        case 1:
          for (int i = 1; i < 7; i++) {
            ShiftPWM.SetOne(VuL[i], LOW);

then it come this what is this??.. what is mean green? lads are green any way?? or red
actualy are 4 green 2 yellow and 1 red. but it doesn’t matter the color of the led.

ShiftPWM.SetOne(VuL[0], green);
         break;

more confusing part is this one? my logic tells that if the number is 2 then the led number 2 will light
but the it says if number is 2 then go to 0?

case 2:
          for (int i = 2; i < 7; i++) {
            ShiftPWM.SetOne(VuL[i], LOW);
          }
          for (int i = 0; i < 2; i++) {
            ShiftPWM.SetOne(VuL[i], green);
// led feedback
void handleControlChange(byte channel, byte number, byte value) {

  //handleControlChange

  //int value_ = round(map(value, 0, 127, 0, 7));
  int value_ = value;

  if (value_ != ccLastValue) {

    // Left VU
    if (number == 12) {

      switch (value_) {
        case 0:
          for (int i = 0; i < 7; i++) {
            ShiftPWM.SetOne(VuL[i], LOW);
          }
          break;
        case 1:
          for (int i = 1; i < 7; i++) {
            ShiftPWM.SetOne(VuL[i], LOW);
          }
          ShiftPWM.SetOne(VuL[0], green);

It would be very hekpful if you posted the complete sketch, described what it is doing and how that differs from what it should.

Or you could make a small program, complete, that illustrates your problem.

If you are asking for an explanation of how a feature of the language is working, which implies you didn’t right the code, we can help but

so can a huge variety of learning sources on the internet which can help you learn C/C++.

While you are waiting for any of us.

Also, I figured out that by “no 6” you mean “number 6”, yes? We comfortable with numbers and recognize them straight away, just say “6”…

a7

It looks like you want something like this:

// VU LEDS
void VU_LEDS(byte value)
{
  if (value > 7)
    value = 7;

  if (value_ == ccLastValue)
    return; // No change so nothing to do

  for (int i = 0; i < 7; i++)
  {
    // Set the LEDs below 'value' to 'green' (HIGH?)
    // Set the LEDs above 'value' to LOW (off)
    if (i > value)
      ShiftPWM.SetOne(VuL[i], LOW);
    else
      ShiftPWM.SetOne(VuL[i], green);
  }

  ccLastValue = value;
}

// led feedback
void handleControlChange(byte channel, byte number, byte value)
{
  if (number == 12)
  {
    // VU Meter
    VU_LEDS(value);
  }
}

i solve the problem :slight_smile:

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