CODE doesn't workd , please HEEEELP !!!!

Hi, this is the CODE:

int val=0;

void setup() {
pinMode(1, OUTPUT);
pinMode(3, OUTPUT);
pinMode(7, INPUT);
}

void loop() {
digitalWrite(1, 1);
val=digitalRead(7);
digitalWrite(3, val);
delay(1000);
digitalWrite(1, 0);
digitalWrite(3, 0);
delay(1000);
}

By this way I need to read the status of the pin 1 into the pin 7 and as consequence swithc on the led in pin 3. I don’t understand why it doesn’t works. Probably the proble is in the connection for the pin 7 ???
I attach the schematic.

Thanks in advance for any precious help, and sorry for my bad english ? :slight_smile:

What is connected to pin 1 and why are you using it when it is normally used by the hardware serial class ?

I see that you don't have any current limiting resistors in series with the LEDs. Is this deliberate ?

I don't understand why it doesn't works.

What happens when you run it ?

What is connected to pin 1

From the diagram, it appears to be an LED. Why OP is expecting that to act as an input device is a mystery. How that is to be powered is a mystery, too.

Please add some resistors between the LEDs and ground or the LEDS and the Arduino pins. It might be healthier for the Arduino :wink:

And from the schematic, you are reading the status of pin 3 into pin 7 (as they are the two that are connected together).