Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Blink LED on Wemos D32 Pro
#1
This seems ridiculous to post, but I'm at a loss for how to even blink an LED on the Wemos D32 Pro.

Code:
from machine import Pin
led = Pin(5, Pin.OUT)

When I run the above (in REPL), the LED immediately turns on. However I cannot manipulate the LED any further than that.
Code:
>>> led.low()
Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
AttributeError: 'Pin' object has no attribute 'low'
>>> led.off()
Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
AttributeError: 'Pin' object has no attribute 'off'

Ok, so Looking at dir() I find there is no functions like are on the Micropython for the ESP8266, at least for output. Am I missing something critically obvious here?

Code:
>>> dir(Pin)
['__class__', '__del__', '__name__', 'IN', 'INOUT', 'INOUT_OD', 'IRQ_ANYEDGE', 'IRQ_DISABLE',
'IRQ_FALLING', 'IRQ_HILEVEL', 'IRQ_LOLEVEL', 'IRQ_RISING', 'OUT', 'OUT_OD', 'PULL_DOWN',
'PULL_FLOAT', 'PULL_UP', 'PULL_UPDOWN', 'init', 'irqvalue', 'value']


Running version: MicroPython ESP32_LoBo_v3.2.24 - 2018-09-06 on ESP32 board with ESP32

Apparently the answer is value(), swore I tried that before posting. Oy. Here's the full version if anyone else cares about this "Hello World" code.

Code:
from time import sleep
from machine import Pin
led = Pin(5,Pin.OUT)
while True:
   led.value(1)
   sleep(1)
   led.value(0)
   sleep(1)
Reply
#2
You should also look into machine.Signal . It will allow you to use pin.off()/.on() and set up each pin for logic inversion.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)