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://forumtest.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