I am a year 10 highschool student and haven't ever used Arduino until a couple months ago. I found a RGB code online and coped it into IDE, then I changed it so that the LED's would flash red and blue fast. That worked, now i have been trying to make it so that the LED's flash different colors instead of changing from red to blue at the same time, like this diagram.
Im using an Arduino Uno Rev 3. The LED's are 4 KY-016 LED Modules and 1 KY-009 LED Module.
int red_light_pin= 11;
int green_light_pin = 10;
int blue_light_pin = 9;
void setup() {
pinMode(red_light_pin, OUTPUT);
pinMode(green_light_pin, OUTPUT);
pinMode(blue_light_pin, OUTPUT);
}
void loop() {
RGB_color(255, 0, 0); // Red
delay(400);
RGB_color(0, 0, 255); // Blue
delay(400);
}
void RGB_color(int red_light_value, int green_light_value, int blue_light_value){
}
{
analogWrite(red_light_pin, red_light_value);
analogWrite(green_light_pin, green_light_value);
analogWrite(blue_light_pin, blue_light_value);
}
This was the code that worked where it changed the lights from red to blue at the same time. I tried just copying it and changing the names of the variables but it didnt work. Im very confused on how to proceed. I want the lights on number 11, 10 and 9 to change to red when numbers 3, 5, and 6 change to blue, and vice versa. Any idea on how to do that? Thanks
welcome to the arduino-user-forum,
a like for posting code as a code-section. Well done.
As you have experienced with your attempt to modify the code with only a small knowledge about programming this does not work.
There are some fundamental basic rules about syntax and about programming that you should learn. Without a basic knowledge your communication in the forum would be "remotely instructed keyboard-typing without understanding anything"
I don't know what a learning-type you are. You can
Take a look into this tutorial:
It is easy to understand and has a good mixture between explaining important concepts and example-codes to get you going. So give it a try and report your opinion about this tutorial.
As a next learning-step
I want to support in a way that fits to your knowledge-level
please post what you think / what you assume what these lines of code do
This means that your braces { and } do not matched up.
Each function must start with a { and end with a }
You can not define a function inside another function.
This is an international forum and this will mean little to any non UK resident. Even if you live in the UK it will mean nothing to people over 50 due to when this numbering system was adopted.
I asked my wife, who was a teacher, how old you would be and she said about 15 about to take your GCSE exam. In my day that would be known as a forth form student, which would mean nothing to you, would it? Not criticising just trying to increase your general education.