Well the pins on the board are different then the GPIO pins. Look at the pictures that describe how the pins are different.
Step 2: Install the Esp chip on Arduino IDEFollowing the images:
- Go into the preferences and go into additional boards manager add this URL ("http://arduino.esp8266.com/stable/package_esp8266com_index.json") then save that.
- Install the ESP boards in the boards manager.
Easy!
Step 3: Use an array for your pinsA super easy way to convert your board pins to the GPIO pins is to use this array.
int pin[]{16, 5, 4, 0, 2, 14, 12, 13, 15};
So now to use the pins how they are used on the board just use "pin[whateverpinislistedontheboard]
"
The codes above will blink the on board LED's (the ESP8266 12-E has two), the LED on the Wi-Fi chip is connected to D0 and the LED on the main board is connected to D4. Use the following code to flash the led's back and fourth:
int pin[]{16, 5, 4, 0, 2, 14, 12, 13, 15};
void setup() {
pinMode(pin[0], OUTPUT); //this would actually be GPIO 16
pinMode(pin[4], OUTPUT); //this would actually be GPIO 0
}
void loop() {
digitalWrite(pin[0], HIGH);
digitalWrite(pin[4], LOW);
delay(500);
digitalWrite(pin[0], LOW);
digitalWrite(pin[4], HIGH);
delay(500);
}
Comments
Please log in or sign up to comment.