LED circuit won’t function

Hi.

I can’t get my LED circuit to work - only if I put a cord to nr 13, but that won’t help me getting the three LED’s to light up.

The code
/* Projekt 1: blink med 3 LED’er */

void setup() {

pinMode(9, OUTPUT);

pinMode(10, OUTPUT);

pinMode(11, OUTPUT);

}

void loop() {

digitalWrite(11, HIGH); // turns on red

digitalWrite(9, LOW); // turns off green

delay(1000); // wait for 1 second

digitalWrite(10, HIGH); // turns on yellow

digitalWrite(11, LOW); // turns off red

delay(1000); // wait for 1 second

digitalWrite(9, HIGH); // turns on green

digitalWrite(10, LOW); // turns off yellow

delay(1000); // wait for 1 second

}

Hi, @nisaku
Welcome to the forum.

Have you checked that the LEDs are connected the right way around?

Instead of connecting the LEDs to the output pins, what happens when you connect the wire to 5V?
Do they light up?

What values are your current limit resistors on the LEDs?

Thanks.. Tom... :smiley: :+1: :coffee: :australia:

...........................................................................
Help us help you.

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the </> icon above the compose window) to make it easier to read and copy for examination

Use the IDE autoformat tool (ctrl-t or Tools, Auto format) before posting code in code tags.

Include the entire error message. It is easy to do. There is a button (lower right of the IDE window) called "copy error message". Copy the error and paste into a post in code tags. Paraphrasing the error message leaves out important information.

Post a schematic.

Post an image of your project.

Which Micro Controller are you using?

Is this simulator code?

Please describe the problem better then you just did.

......................................................................

If you are using a 9V battery like this.


Don't.

.................................................................

Info about multi things

.......................................................................................................................

I2C scanner

What did the I2C scanner report?

.........................................................................................
Bread board power rail split


...............................................................................................................................................
Serial Input basics.

................................................................................................................

The search box is a useful tool.


For instance using the words "9v battery" in the search box one could find lots of reasons why this may be a bad idea.

Other search words include "level shifter",
.........................................................................................................

code merging

http://www.thebox.myzen.co.uk/Tutorial/Merging_Code.html

..........................................................................................................

disclaimer

The events portrayed in this post are not all true. The names are not real names of real people and real organizations.
..............................................................................

Did you try wiring the LEDS the other way?

Thank you for your quick respond - I’m very new in this. First year of biomedical engineering.

Well, I have made the circuit our from a model our teacher provided us.
All the LED’s are accurately placed. They work - if I put the cord to output 13 :upside_down_face:

If I put the cords to 5v all of the LEDs are Lightning up, but don’t blink which is a part of the assignment.

Thank you again!

The resisters should be 10kOhm

Your topic has been moved to a more suitable location on the forum. Introductory Tutorials is for tutorials that e.g. you write, not for questions. Feel free to write a tutorial once you have solved your problem :wink:

Please edit your opening post, select all code and click the </> button to apply so-called code tags and next save your post. It makes it easier to read, easier to copy and the forum software will display it correctly.

Are you sure you have uploaded the sketch to the board?

2 Likes

What about other pins, like 2-7, or A0-A5?

I don't see anything obviously wrong (nothing obvious to me...).

I recommend going back to the Blink Example. Move one of the wires to pin-13 and make sure the external LED blinks along with the built-in LED. If that doesn't work you have some kind of wiring/hardware problem.

If that works move the connection back to pin-9, 10, or 11,and modify the blink code to blink that pin instead of pin-13 (or in addition to pin-13). If that doesn't work, maybe your Arduino is bad.

If the blink example does work with a different pin, just keep adding one or two lines of code at a time until it blinks all of the LEDs as expected.

??? The resistors for the LEDs should be no greater than probably 330 ohms.

Did you select the appropriate com port then upload your sketch?
Note: The "blink" sketch was probably pre-installed.

It's never too early to start putting

  Serial.begin(9600);

in your setup() function, then placing

Serial.println(" note to self ");

kinda statements in the code to see if it has even up.loaded and is running according to your plan. You can also,print the values of variables and so forth. Very handy.

Open the serial monitor window, make sure the baud rate is set to match the Serial.begin(9600) and see inside the code as you desire.

a7

That's what I am thinking. Everything else looks to be ok.

Interesting.

Ahh, yes, as per reply #6!

Yeah, image should not light up with the OP's sketch.

In setup(), after Serial.begin(9600);

   Serial.println("I am the sketch you just uploaded!");

I have been reduced to doing this when nothing is making sense.

But the copious output produced during that the compile/upload should be enough to give you confidence that you are running what you have written.

a7

Thank you for all your responses!
I’ve tried on THREE different Arduino Uno devices now, and two breadboards…. Same (shit)!
It only blinks if I connect the LED to nr 13, which isn’t even in my code.
They all light up if I put them in the 3.3/5V.

What a beginning :partying_face:


The sketch!

That's an indication that the program installed by the manufacturer has in fact not been overwritten. You have yet to produce any evidence of a successful upload - it appears at the bottom of the progress window when you've successfully uploaded the code. There are two steps, compile and upload - is it possible you've only compiled, but not uploaded?

It should have uploaded, no errors :woman_shrugging:t3:

Cannot see any evidence of uploading in your screen picture. Sorry.

Look under SKETCH on the menu at the top.
You should see the UPLOAD option in there (though I'm not familiar with IDE 2.x.x).