This tutorial of Robo India explains the basics of input and output programming in physical computing world. This tutorial teaches how to take analog output from NodeMCU.
1. Introduction:
A signal with respect to time has some value. In case of an analog signal it may has any value. In the Node MCU it may has values between GND and VCC. VCC can be 3.3V. If a Node MCU is operating on 3.3V then an analog output can have any value between 0 volt to 3.3 volt. An analog signal may have 1.2v or 2.3v or any other value between 0 and 3.3 unlike digital output which has only two options 0 or 3.3V.
If an LED is connected to an analog output it glows maximum on a signal of 3.3V and glows minimum at 0V. The minimum glow of an LED is zero (LED off). When output varies from 0 to 3.3V the LED shows fed in and fed out effects.
This tutorial is for NodeMCU on Arduino IDE. Please note that the same tutorial can be performed on LUA as well.
1.2 Hardware required
S.No. | Item | Quantity |
1 | NodeMCU | 1 |
2 | Breadboard | 1 |
3 | LED | 1 |
4 | Resistor 1k | 1 |
5 | Jumper Male to male | 4 |
2. Building Circuit
Schematic Diagram:
Circuit Layout:
3. Programming:
Once the circuit part is done, NodeMCU is needed to be programmed. Here is the code to run this circuit on NodeMCU.
You may download this code (Arduino Sketch) from here.
// Robo India Tutorial // Digital Input and Output on LED // Hardware: NodeMCU const int LED_ao = 4; void setup() { pinMode(LED_ao, OUTPUT); } void loop() { for (int brightness=1; brightness<=255; brightness++) { analogWrite(LED_ao, brightness); delay(10); } for (int brightness=255; brightness>0; brightness--) { analogWrite(LED_ao, brightness); delay(10); } }
4. Output
The execution makes fed out effects on the LED. To vary speed of fed in and out effect try changing delay.
5. Troubleshooting
LED is not glowing: – Try changing polarity of LED, Pull it out rotate it by 180 degree and insert its again.
If still not working pull the led out and test it may be defective
If you have any query please write us at support@roboindia.com
Thanks and Regards
Content Development Team
Robo India
https://roboindia.com