Created
January 29, 2018 17:07
-
-
Save ShakataGaNai/23d2bef5fd17232ba9e178abb9e995df to your computer and use it in GitHub Desktop.
A hello world (blinking LED) for Micropython on the Wemos D1 Mini (ESP8266)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# See https://obviate.io/?p=8022 for more details | |
import time | |
from machine import Pin | |
led = Pin(2, Pin.OUT) | |
while True: | |
if led.value(): | |
led.off() | |
else: | |
led.on() | |
time.sleep_ms(250) |
On my WeMos NodeMCU ESP8266 led pin is inverted. Use machine.Signal
for this case https://github.com/micropython/micropython/blob/master/examples/hwapi/hwconfig_esp8266_esp12.py#L5.
from machine import Pin
from machine import ADC
from time import sleep_ms
x = ADC(Pin(2, Pin.IN))
y = ADC(Pin(5, Pin.IN))
x.atten(ADC.ATTN_11DB)
y.atten(ADC.ATTN_11DB)
while True:
x_val = x.read()
y_val = y.read()
print('Current position:{},{}'.format(x_val,y_val))
sleep_ms(300)
Traceback (most recent call last):
File "<stdin>", line 5, in <module>
TypeError: can't convert Pin to int
what is the issue here ?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Correct, one in the same. In micropython its based on the GPIO number, rather than A/D labels, very confusing, I know. Look at https://randomnerdtutorials.com/esp8266-pinout-reference-gpios/ who's got a good list of the different pinout's.