The code should be correct, at least I don't get an error message. But something must be wrong with my wiring, since nothing happens (see attachments). I hope you can see what's going on in the picture: The two resistances are not on the same rail. As far as I know, the breadboard is internalle connected along a vertical line but not horizontally. So I really don't know why this is wrong.
Can anyone please help me out ? ( I know probably a really stupid question).
Everything is wrong with your wiring. Most of the wires connect to nothing at all. Have you looked at which pins are common on the breadboard?
It would behoove you to draw a proper schematic and show an image here so we can see directly how you are trying to implement this. Actually, it should have been your first step.
What do you mean by "have you looked at which pins are common on the breadboard?"
Anyways, I think I missunderstood the breadboard: it seems only the outermost two columns are connected vertically and the ones in the middle are connected horizontally. So I corrected my wiring and it is still wrong. I am trying to implement the sketch that you can see in the attachements as well. This is a sketch for the Arduino Uno and I am trying to implement it on the Mega2560, but it shouldn't be of any difference now, should it?
What do you mean by "have you looked at which pins are common on the breadboard?"
It means do you know how the breadboard works?
Anyways, I think I missunderstood the breadboard: it seems only the outermost two columns are connected vertically and the ones in the middle are connected horizontally.
You just figured out how a breadboard works.
So I corrected my wiring and it is still wrong. I am trying to implement the sketch that you can see in the attachements as well. This is a sketch for the Arduino Uno and I am trying to implement it on the Mega2560, but it shouldn't be of any difference now, should it?
First check that you can light the LED from the +5V pin via resistor, get that working first, then
connect resistor to the Arduino pin. Post your code (in code tags) if its changed.
For others folloing this thread who aren't "old hands" with breadboards... which are worth their weight in gold, by the way, and come in many shapes and sizes... see...