This tutorial of Robo India explains the basics of input and output programming in physical computing world. This tutorial teaches how to take digital output from NodeMCU on Arduino IDE. The output is taken on LED, It glows for a second and remain off for a second.
1. Introduction:
A step by step illustrated very basic tutorial for digital input and output in physical computing. Here we are taking digital output on a LED. This LED remains ON for one second and OFF for another, this loop runs for an infinite time.
This tutorial is for NodeMCU on Arduino IDE. Please note that the same tutorial can be performed on LUA as well.
1.1 LED Pins:
LED has two pin interface. Both of these pins are to be given input supply to the LED. Long legs is for positive supply the smaller one is for negative supply. following image depicts it clearly.
Digital means either 0/1, in other words HIGH/LOW or ON/OFF. So in the form of digital output we shall get either +5V or 0V on digital pin of Arduino. How does it happen that is illustrated ahead.
S.No. | Item | Quantity |
1 | NodeMCU | 1 |
2 | Breadboard | 1 |
3 | LED | 1 |
4 | Resistor 1k | 1 |
5 | Jumper | 4 |
2. Building Circuit
Schematic Diagram:
Circuit Layout:
3. Programming:
Once we are done with the circuit part, here is our program for this circuit.
But before that, we need to understand the digital pin nomenclature of NODEMCU board.
While programming in Arduino we will use GPIO pin number instead of pin number printed on the NODEMCU board.
For example D2 -> GPIO 4
// Robo India Tutorial // Digital Input and Output on LED // Hardware: NodeMCU const int LED = 4; void setup() { pinMode(LED, OUTPUT); } void loop() { digitalWrite(LED, HIGH); delay(1000); digitalWrite(LED, LOW); delay(1000); }
4. Output
After successful uploading of the code, the execution of the code makes the LED on for one second and off for another one second. This happens in an infinite loop. Thus the LED keeps blinking.
5. Troubleshooting
LED is not glowing: Try changing polarity of LED, Pull it out, rotate it by 180 degree and insert bit again.
Code uploading error: The code will only be uploaded when there is no error in the code. Try removing error, if any.
General error: Never keep open circuit including NodeMCU on a metallic surface. It may shorten the circuit.
If you have any query please write us at support@roboindia.com
Thanks and Regards
Content Development Team
Robo India
https://roboindia.com