This tutorial of Robo India explains the basics of input and output programming in physical computing world. This tutorial teaches how to take digital input and show that as an output on ESP-01(ESP8266) on Arduino IDE. The input is taken through switch and the output is taken on LED, the LED glows when button is pressed.
1. Introduction
This is a breakout board for popular ESP-01(ESP8266) module operated at 5 Volt.
The ESP8266 is designed by a Chinese company Espressif .It is a simple application and they easy add a connectivity to another microcontroller, which is very limited number of exposed pins
ESP-01(Esp8266) is a basic tutorial for Arduino IDE. In this tutorial we are taking digital input from a push button switch. Thus this tutorial is for both digital input and digital output.

1.2 Hardware required
S.No. | Item | Quantity |
1 | FTDI Basic | 1 |
2 | ESP8266 ESP-01 Breakout Board | 1 |
3 | Breadboard | 1 |
4 | LED | 1 |
5 | Resistor 10k | 1 |
6 | Jumper Male to male | 6 |
7 | Push Button Switch | 1 |
Users can buy ESP-01(ESP8266) from Robo India Shop: https://roboindia.com/store/esp8266-esp01-breakout-board
2. Features
These pins function as follows:
1) Can be programmed using standard 5v FTDI Module.
2) Separate Pin Out for mounting on Breadboard.
3) On board flash and Reset switch.
4) Inbuilt 3.3v Voltage Regulator.
3. How to set up ESP-01(ESP8266) in programming mode
Connect the FTDI to your PC through a USB port. The red led of the ESP module will switch on.
The button on the side of the breadboard is reset button, while the other button is the is GPIO0.
1) Press the GPIO0 button and keep it pressed.
2) Press the reset button and keep it pressed
3) Release the reset button
4) Release the GPIO0 button
If a blue light will switch on momentarily on the ESP module, then your ESP is in programming mode.

4. Connections

5. Programming:
Once we are done with circuit part, here is our programme to this circuit.
You may download this code (ESP-01 Sketch) from here.
const int BUTTON=2; const int LED=0 ; int BUTTONState=0; void setup() { // put your setup code here, to run once: pinMode(LED,OUTPUT); pinMode(BUTTON,INPUT); } void loop() { // put your main code here, to run repeatedly: BUTTONState=digitalRead(BUTTON); if(BUTTONState==HIGH) { digitalWrite(LED,HIGH); } else { digitalWrite(LED,LOW); } }
6.Upload Your Sketch
1) Open the Arduino IDE.In the Arduino IDE, under Tools –> Board, select “Generic ESP8266 Module”.

2) Select the port in which the ESP module is connected.
3) Than copy and paste the code in Arduino IDE
7. Output
After successful uploading of the code, try pressing and releasing the button, the LED glows if the button is pressed and gets off when the button is released.
8. Troubleshooting
LED is not glowing: Try changing polarity of LED, Pull it out, rotate it by 180 degree and insert bit again.
Still not glowing: Check the switch with multimeter, it’s terminal should be connected in pressed condition and vice-versa.
If you have any query please write us at info@roboindia.com
Thanks and Regards
Content Development Team
Robo India
https://roboindia.com