Blinking Led Program using Micro-python on Nodemcu

Micro-Python  is a software implementation of the Python 3 programming language, written in C, that is optimized to run on a microcontroller. Micro-Python is a full Python compiler and runtime that runs on the micro-controller hardware. The user is presented with an interactive prompt (the REPL) to execute supported commands immediately. Included are a selection of core Python libraries, Micro Python includes modules which give the programmer access to low-level hardware.
Here in this blog Iam just working on Nodemcu 12-E micro-controller for blinking of Led. The pin diagram for the connection is given in the fig.

We all know about the blinking of led program the algorithm for the blinking is that , the led get on for some small span of time and it get off .After getting for sometime it get on again and this process goes on. It on us how many times we want to get that led blink.   


Now we have to code......
For coding we can use 2 softwares 
1.Esplorer(for downloading click here esplorer)
2.Espcut (for downloading here espcut)
We can also use REPL socket Protocol (documentation)

After the IDE get started connect the Nodemcu 12-E board 
for connection watch this video(working with ESPLORER and connection with Nodemcu)


Connection diagram is given below:

 

fig: Connection diagram

You will need :
1. Led
2. 220ohm resistor
3. Nodemcu microcontroller
4. Connecting Wire

Steps :
1. Connect Led on D0 pin of controller using resistor.
2. Then connect it to ground.

Program:

The program will be written in Micro-python language.




import machine                   // module which defines micropython program is there
import time                         // module for delay
led = machine.Pin(16, machine.Pin.OUT)                 //declaration of pin
while True:
          led.on()                           // led on
          time.sleep(1)                  // delay
          led.off()                            // led off
          time.sleep()  
........................................................................................................................................................
                        Program End
.........................................................................................................................................................

Comments

  1. the second time.sleep() is wrong
    it should be
    time.sleep(1)

    ReplyDelete
  2. I love ESPCut, but V0.78 refuses to handle files that end with .py!? Anyone have the same problem? Where could I find a version that doesn't suffer from this problem? Is there a work-around?

    ReplyDelete

Post a Comment

Popular posts from this blog

Finding Time elapsed in doing work using MicroPython

Connecting NodeMcu to a network using Micro Python