Skip to content

Instantly share code, notes, and snippets.

@lamoboos223
Last active April 1, 2024 03:17
Show Gist options
  • Save lamoboos223/189f9e686184f7c5b6f50a39edf00f0d to your computer and use it in GitHub Desktop.
Save lamoboos223/189f9e686184f7c5b6f50a39edf00f0d to your computer and use it in GitHub Desktop.
connect esp8266 to output a value to arduino uno where arduino reads this value and do some action

Arduino code

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);   // Initialize the serial communication

  pinMode(7, INPUT);

}

void loop() {
  int pinState = digitalRead(7);  // Read the state of the pin

  if (pinState == HIGH) {
    Serial.println("Pin is HIGH");  // Print a message if the pin is HIGH
  } else {
    Serial.println("Pin is LOW");   // Print a message if the pin is LOW
  }
  delay(2000);
}

Esp8266 code

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);   // Initialize the serial communication

  pinMode(14, OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
  digitalWrite(14, HIGH);
  Serial.println("Pin is HIGH");  // Print a message if the pin is HIGH
  delay(2000);
  digitalWrite(14, LOW);
  Serial.println("Pin is LOW");   // Print a message if the pin is LOW
  delay(2000);
}

Wiring

ESP8266 Arduino uno
Vin 5V
GND GND
14 7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment