Simple Wifi connect and toggle garage door opener with D5

Simple issue with Arduino & ESP2866 programming.
Getting function-definition error when compiling void loop of this code. I am a novice and am learning.
a function-definition is not allowed here before ‘{’ token
Thank you in advance.

#include <ESP8266WiFi.h>
#define SERIAL_BAUDRATE 115200
#define LED 2

// Replace these with your WiFi network settings

const char* ssid = “MyWifiName”; //replace this with your WiFi network name
const char* password = “MyPassword”; //replace this with your WiFi network password
const char* myHostname = “Garage”; //replace this with yor WiFi hostname

void setup(){

WiFi.hostname(“Garage”); // change name for router detection
WiFi.begin(ssid, password);

// Init serial port and clean garbage
while (WiFi.status() != WL_CONNECTED)

Serial.print("IP Address is: ");

//set Pin to D5
pinMode(5, OUTPUT);

void loop() {

//momentary toggle

digitalWrite(5, !digitalRead(5));

You are missing a '}' before loop()

Hi, Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.,148850.0.html then look down to item #7 about how to post your code. It will be formatted in a scrolling window that makes it easier to read.

Thanks.. Tom. :)

arduino_new: You are missing a '}' before loop()

I think that it is interesting that almost everyone that makes this mistake insists on putting curly braces on the line with the function name/statement. Those who put the opening curly brace on a new line rarely miss the closing brace.