how to enable and disable two different pins in esp 8266

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
sundeepgorantla95
Posts: 1
Joined: Wed Oct 26, 2016 9:49 am

how to enable and disable two different pins in esp 8266

Post by sundeepgorantla95 » Wed Oct 26, 2016 9:57 am

Haii
I want a certain pin of ESP8266 to be enable for some time and after that certain time it should be disabled and other pin should be enabled.
While one is enabled the other should be disabled.
How can we implement this using MicroPython Code?
Thanks

chrisgp
Posts: 41
Joined: Fri Apr 01, 2016 5:29 pm

Re: how to enable and disable two different pins in esp 8266

Post by chrisgp » Wed Oct 26, 2016 4:43 pm

Yes that should be pretty straightforward. Something like the following will flip the value of two pins before waiting five seconds to do it again.

Code: Select all

import time
from machine import Pin

pin_a = Pin(4, Pin.OUT)
pin_b = Pin(5, Pin.OUT)

while True:
    pin_a.value(1)
    pin_b.value(0)
    time.sleep(5)
    
    pin_a.value(0)
    pin_b.value(1)
    time.sleep(5)

Post Reply