From 6d54b09b9aac9e748ebad045d7e3797040c61af7 Mon Sep 17 00:00:00 2001 From: Ashutosh Jha Date: Fri, 4 Oct 2019 19:10:16 +0530 Subject: [PATCH 1/2] Added Connecting_to_wifi py file to Nodemcu examples --- 02_Connecting to Wifi/readme.md | 7 +++++++ 02_Connecting to Wifi/wifi_connect.py | 9 +++++++++ 2 files changed, 16 insertions(+) create mode 100644 02_Connecting to Wifi/readme.md create mode 100644 02_Connecting to Wifi/wifi_connect.py diff --git a/02_Connecting to Wifi/readme.md b/02_Connecting to Wifi/readme.md new file mode 100644 index 0000000..033fc4e --- /dev/null +++ b/02_Connecting to Wifi/readme.md @@ -0,0 +1,7 @@ +# 02_Connecting_to_Wifi +To run the program use the following ampy command + + +```bash + ampy --port /dev/tty.SLAB_USBtoUART run wifi_connect.py +``` diff --git a/02_Connecting to Wifi/wifi_connect.py b/02_Connecting to Wifi/wifi_connect.py new file mode 100644 index 0000000..b977084 --- /dev/null +++ b/02_Connecting to Wifi/wifi_connect.py @@ -0,0 +1,9 @@ +import network + sta_if = network.WLAN(network.STA_IF) + if not sta_if.isconnected(): + print('Connecting to network...') + sta_if.active(True) + sta_if.connect('', '') + while not sta_if.isconnected(): + pass + print('Network config:', sta_if.ifconfig()) \ No newline at end of file From 0bb2d4599c764e889331b350a96b61f06e67ac42 Mon Sep 17 00:00:00 2001 From: Ashutosh Jha Date: Fri, 4 Oct 2019 19:28:32 +0530 Subject: [PATCH 2/2] Added RGB LED Program using micropython --- 02_Connecting to Wifi/readme.md | 1 + 03_RGB_LED/readme.md | 10 ++++++++++ 03_RGB_LED/rgb_led.py | 20 ++++++++++++++++++++ 3 files changed, 31 insertions(+) create mode 100644 03_RGB_LED/readme.md create mode 100644 03_RGB_LED/rgb_led.py diff --git a/02_Connecting to Wifi/readme.md b/02_Connecting to Wifi/readme.md index 033fc4e..f0e20ac 100644 --- a/02_Connecting to Wifi/readme.md +++ b/02_Connecting to Wifi/readme.md @@ -1,4 +1,5 @@ # 02_Connecting_to_Wifi +This program is to connect to WiFi using NodeMCU To run the program use the following ampy command diff --git a/03_RGB_LED/readme.md b/03_RGB_LED/readme.md new file mode 100644 index 0000000..ff2e697 --- /dev/null +++ b/03_RGB_LED/readme.md @@ -0,0 +1,10 @@ +# 02_RGB_LED_COLOUR_VARIATIONS +- This program is for controlling RGB LED using NodeMCU +- Run this program after setting up the hardware part. For more information visit : +[Controlling RGB LED using NOdeMCU](https://blog.thepodnet.com/nodemcu-rgb-led-using-micropython/) + +After setting up the circuit, run the program by using following ampy command in terminal + +```bash + ampy --port /dev/tty.SLAB_USBtoUART run rgb_led.py +``` diff --git a/03_RGB_LED/rgb_led.py b/03_RGB_LED/rgb_led.py new file mode 100644 index 0000000..7accd67 --- /dev/null +++ b/03_RGB_LED/rgb_led.py @@ -0,0 +1,20 @@ +import machine +import time + +blue = machine.Pin(14, machine.Pin.OUT) +red = machine.Pin(12, machine.Pin.OUT) +green = machine.Pin(13, machine.Pin.OUT) + +while True: + green.on() + time.sleep_ms(500) + green.off() + time.sleep_ms(500) + blue.off() + time.sleep_ms(500) + blue.on() + time.sleep_ms(500) + red.on() + time.sleep_ms(500) + red.off() + time.sleep_ms(500) \ No newline at end of file