I am quite new to Arduino. when I uploaded the code, the lights on the Uno flashed and nothing happened.
I have tried rearranging the wires and trying something simpler but still, nothing happened.
the program software hadn't shown any errors either.
We don't know what code you uploaded, so we don't know what you expected to happen.
ah, sorry
int r = 0;
int g = 0;
int b = 200;
int counter;
int ColSpeed = 20;
int ColSpped2 = 5;
int pr = 6;
int pg = 3;
int pb = 5;
void setup()
{
pinMode(3, OUTPUT);//green
pinMode(5, OUTPUT);//blue
pinMode(6, OUTPUT);//red
}
void loop()
{
counter = 0;
// blue to red
for (counter = 0; counter < ColSpeed; counter++) {
b -=ColSpped2;
r +=ColSpped2;
analogWrite(pr, r);
analogWrite(pb, b);
delay(20);
}
counter = 0;
//red to greem
delay(200);
for (counter = 0; counter < ColSpeed; counter++) {
g +=ColSpped2;
r -=ColSpped2;
analogWrite(pg, g);
analogWrite(pr, r);
delay(20);
}
counter = 0;
//green to blue
delay(200);
for (counter = 0; counter < ColSpeed; counter++) {
b +=ColSpped2;
g -=ColSpped2;
analogWrite(pg, g);
analogWrite(pb, b);
delay(20);
}
counter = 0;
delay(10); // Delay a little bit to improve simulation performance
}
its meant to slowly shift the color of RGB lights
I tried this code in tinkercad and it worked but my Uno isn't running it
How do you know it isn't running?
You have no Serial prints in it, so it could be the wiring that you didn't show us that is at fault.
pinMode(6, OUTPUT);
You gave the pins names; use them (pins used for analogWrite don't need a pinMode)
(What is "tinkercad"?)
(deleted)
tinkercad is a website that I use to simulate my Arduino circuits, it's free you should try it
I am very sure the wiring is correct because of tinkercad and I googled what the pins are on RGB leds
the resistors are from the starter kit which I'm assuming are for LEDs
So, you've added some debug prints, and you're still convinced the code isn't running?
metalmaniac377:
the resistors are from the starter kit which I'm assuming are for LEDs
What value are they though? It may be that the pins are outputting correctly but the resistors are too high a value, the current's very low, and the leds are so dim as to be effectively off.
Assuming is never a good idea: measure them with your meter and or read the bands.
I just ran your code on an Uno with discrete r, g and b leds (not an rgb led) and they do all fade in and out. I didn't check the fading against the code
but there is certainly regular activity.
And (no surprises) It also works on an rgb.
metalmaniac377:
tinkercad is a website that I use to simulate my Arduino circuits, it's free you should try it
I'll pass, thanks.
To misquote H2G2's Roosta, if you can't scratch a window with it, I don't trust it.
(deleted)
the resistors are 1300 MOhms, I don't know if that is good or bad
I have tried to debug print but like everything else, nothing happened
the resistors are 1300 MOhms
That's 1.3 GOhm... I think you may be misreading the bands.
But a resistor for an led should typically be a few hundred ohms, although I use up in the 1000s if the leds are very bright.
Here's a resistor colour band de-coder
I tried it without a resistor, still nothing. so if it isn't the resistor, the programming or the led what is it?
I just got a new Arduino and its also not running code (but the lights flash)
it's likely my software then.
metalmaniac377:
I tried it without a resistor,
Why would you do that? ![]()
metalmaniac377:
I just got a new Arduino and its also not running code (but the lights flash)it's likely my software then.
Not running any code or just your code?
What about good old Blink, or a sketch that Serial prints some messages?
metalmaniac377:
I just got a new Arduino and its also not running code (but the lights flash)it's likely my software then.
What do you mean by this, what lights flash?
Have you uploaded the "Blink without delay" to see if the on board LED flashes?
Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?
Can you please post a picture of your project so we can see your layout?
Tom...