Vellerman WMA307

I have been trying to get the VMA307 (Arduino Compatible RGB Module) to work using the provided code in the instruction manual. However, it just doesn’t work bring up a number of errors.

I’ll admit I am just learning how to code for an Arduino, hence why the provide code is helpful. I have found other code but it doesn’t seem as tidy to implement within a large program.

I initially tired Exmple 2 (random colours) but when that failed to work I went back to Example 1 to try and get just one colour to illuminate.

The key error coming up is that “setColor” isn’t defined.

I would be grateful for some direction on how to make this work.

Hello !

Can you show us you arduino sketch / .ino file ?
and the exacte error under Arduino IDE ? (screen shot or in a code block )

On this forum if you want to insert code you have to use markdown Extended Syntax | Markdown Guide
use three backticks (````` ) or three tildes (~~~ ) on the lines before and after the code block.

/**
 * Exemple sketch for WMA307 https://www.velleman.eu/products/view/?country=be&lang=fr&id=435528
 * from https://www.velleman.eu/downloads/29/vma307_a4v01.pdf
 * 
 * adapted by PPAC for DrRusty https://forum.whadda.com/t/vellerman-wma307/34856
 * 
 * Date 02/12/2021 (dd/MM/yyyy)
 * 
 * Status : 
 * - no compilation error (Arduino IDE v1.8.15 ( Arduino AVR Boards 1.6.23 ) Environnement Arduino UNO )
 * - fonctionnal ???
 * 
 * Arduino References Documentation :
 * - https://www.arduino.cc/reference/en/
 */


 //RGB LED pins
 // The three digital pins of the digital LED
 // 10 = redPin
 // 11 = greenPin
 // 9 = bluePin 

//int ledDigitalOne[] = {10,11,9};

// For me this is more practical for modification, like this ( but ... as you like ...)
int ledRedPin = 10;
int ledGreenPin = 11;
int ledBluePin = 9;
int ledDigitalOne[] = {ledRedPin,ledGreenPin,ledBluePin};

// Define ON as ????LOW !!!HIGH (this is because we use a common Anode RGB LED ( common pin is connected to +5 volts)
const boolean ON = HIGH;
// Define OFF as ???HIGH
const boolean OFF = LOW;

//Predéfine Colors
const boolean RED[]   ={ ON,  OFF, OFF};
const boolean GREEN[] ={ OFF, ON,  OFF};
const boolean BLUE[]  ={ OFF, OFF, ON};
const boolean YELLOW[]={ ON,  ON,  OFF};
const boolean CYAN[]={ OFF, ON,  ON};
const boolean MAGENTA[]={ ON,  OFF,  ON};
const boolean WHITE[]={ ON,  ON,  ON};
const boolean BLACK[]={ OFF,  OFF, OFF};


// An Array that stores the predefined colors (allow us to later randomly display a color)
const boolean * COLORS[] = { RED, GREEN, BLUE, YELLOW, CYAN, MAGENTA, WHITE, BLACK };

void setup() {
  //Set the three LED pins as output
  for( int i = 0 ; i<3 ; i++){    
    pinMode( ledDigitalOne[i], OUTPUT ); 
  }
}

void loop() {
  /*Ex 1*/
  //Set the color of LED one
  setColor(ledDigitalOne,YELLOW);

  // 1 seconde = 1000 milliseconds
  delay(2000);

  /*Ex 2   */
   randomColor();
}

void randomColor(){
  // get a random number within the range of colors  
  int rand = random(0, sizeof(COLORS) /2); 
  // Set the color of led one to a random color
  setColor(ledDigitalOne, COLORS[rand]);
  // 
  delay(1000);  
}

void setColor(int* led, boolean* color){
   for (int i = 0; i < 3; i++){
      digitalWrite(led[i], color[i]);
   }
}

void setColor(int* led, const boolean* color){
    boolean tempColor[] = {color[0], color[1], color[2]};
    setColor(led, tempColor);
}

// END OF FILE

@DrRusty

It’s difficult for us and other forum members too as @PPAC says also, to know or to see where the the error is located in your situation without see your used code, or used arduino IDE version.
Please describe more in detail the problem, post code, add photo’s, etc
. verry importent.

Possible a copy paste error from PDF (photo of code) to real arduino code,
can be the cause of your error (“setColor” isn’t defined).

Anyway we have test the example code of VMA307 / WPM307 => The code compiles without any errors for Arduino IDE 1.8.16 as IDE2.0.0-beta12 to.

So you can try to copy the code from here posted above. normally it should work.

@PPAC thanks for your support, and how to post Arduino code in our forum. well done :slight_smile: :+1:

Best regards,
Velleman Support

1 Like

Hi

I’ll give copying the code and see if that works, perhaps I have made a copying error.

If that doesn’t work I will post a screen grab of the error.

Thank you

1 Like