Kinda confused and i need your confirmation on pins please. I need to connect some devices in pins 4 and 12 as well. So these are the D2 for gpio 4 and read from micropython as pin 4? Also for pin 12 is D6 for gpio12 and micropython reads it as pin12?
Please advice
Pin setup
Re: Pin setup
Hello good day, apparently you are talking about nodemcu, you are correct, when you connect something in D2 you have to refer to it as pin 4 in micropython and D6 as pin 12.
-
- Posts: 969
- Joined: Sat Feb 03, 2018 7:02 pm
Re: Pin setup
You can use this dict I'm using to get the pin number with nodemcu:
Code: Select all
from micropython import const
pins = {"D0": const(16), "D1": const(5), "D2": const(4), "D3": const(0), "D4": const(2),
"D5": const(14), "D6": const(12), "D7": const(13), "D8": const(15), "D9": const(3),
"D10": const(1)}
Kevin Köck
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode
-
- Posts: 463
- Joined: Wed Apr 08, 2015 5:19 am
Re: Pin setup
Or shorter:
I'm not sure whether const makes sense for dict entries.
Code: Select all
pins = {"D%i" % p: v for p, v in enumerate((16, 5, 4, 0, 2, 14, 12, 13, 15, 3, 1))}