Connect a nodemcu esp8266 to an arduino uno

hello, i want to be able to push a button that is connected to arduino uno and in response, an LED connected to nodemcu will light up. I dont know how to wire up the esp8266 to arduino, and i dont know what should i put in code. Can someone help me? Thank you.

Try DroneBotWorkshop... shows nodemcu and making an LED blink over wifi.
https://dronebotworkshop.com/esp32-intro/

the arduino uno doesnt have wifi, i hoped that is a way to connect the uno with the esp8266 using TX,RX or something like that

There is. You could run a Uno output to an ESP input (through a voltage divider, simple).
Or use serial.
The NodeMCU already has a couple of onboard LEDs, something less to buy.

This shows Uno to Nodemcu on TX/RX... read the voltage divider and Software Serial portions carefully.

i tried to run uno as an output and esp as an input and didnt work, i dont know why

Probably time to share what you tried.

A schematic and sketch goes a long way here.

code for esp8266
void setup() {
// put your setup code here, to run once:
pinMode(D5,INPUT);
pinMode(D8,OUTPUT);
}

void loop() {

int button = digitalRead(D5);
if(button==1)
digitalWrite(D8,HIGH);

}

code for arduino
void setup() {
// put your setup code here, to run once:
pinMode(8,OUTPUT);

}

void loop() {
// put your main code here, to run repeatedly:
digitalWrite(8,HIGH);
}

It's onion peeling time once again.

Onions - yes, many layers to uncover. : )

In the tx/rx example above, there exists a "receiver" and a sketch for the receiver, and a "transmitter" and a sketch for the transmitter. You are only showing one sketch. Do you have both? Would you try the configuration and sketches from the example link? Which device is your transmitter and which is your receiver?

i never got to tried the method with the rx/tx, the sketch from above is for setting the arduino as output pin and the esp8266 as a input pin. I connect the 2 pins using a voltage divider 1k,2k, but i dont know why the esp266 is fried after trying to connect to arduino

i have another esp but i dont want to do the same mistake

You load the same sketch into Uno and esp8266 to configure each? How does the host (uno/esp) know if it is tx or rx?

connect the button to the NodeMCU.
Connect the LED to the NodeMCU.
Disconnect the Arduino from the NodMCU.
Leave away the Arduino.
Just program the NodeMCU.

You can see in this video

First mention of that.
Now there's more than one onion.

Uploading: IM
IMG_5145
G_5146.jpg…

this is how i wire the esp8266 and arduino, the rezistors are 1k and 2k,
the code for arduino:

void setup() {
// put your setup code here, to run once:
pinMode(8,OUTPUT);

}

void loop() {
// put your main code here, to run repeatedly:
digitalWrite(8,HIGH);
}

code for esp8266:

void setup() {
// put your setup code here, to run once:
pinMode(D5,INPUT);
pinMode(D8,OUTPUT);
}

void loop() {

int button = digitalRead(D5);
if(button==1)
digitalWrite(D8,HIGH);

}

void setup() 
{
  // for the Uno
  pinMode(8,OUTPUT);
}

void loop() 
{
  digitalWrite(8,HIGH);
  delay(500):
  digitalWrite(8, LOW);
  delay(1000);
}
//NodeMCU
// no external LED, using onboard LED
int button;
  
void setup()
{
  // NodeMCU
  pinMode(D5,INPUT);
  pinMode(D0,OUTPUT);
}

void loop() 
{
  button = digitalRead(D5)
  if(button)
  digitalWrite(D0,HIGH);
  else
  {
    digitalWrite(D0, LOW);
  }

}

its correct the way i connected the nodemcu with the uno ?