Is there anything different about the way io pins work on an esp8266 ?
I'm trying to port some proven max7219 matrix display code to an esp8266 and couldn't get anything to happen.
So i put the scope on the io pins i thought were in use and nothing is happening. So i put this code in a test program and i can see from the debug print the pins are supposed to toggle every 3 secs. However I can't find any pin on my nodemcu that is changing state ?
FFMan wrote:Is there anything different about the way io pins work on an esp8266 ?
The setup and use are basically the same as with other ZX devices. The problem may lie with the first line that you show; I can't say since the rest of the program isn't shown.
Option UserPostInit myPostInit
Const pin as Byte = A.2
Dim state as Integer
Dim pinState as Byte
Sub Main()
If (state = 0) Then
pinState = pinState Xor 1
Call PutPin(pin, pinState)
Debug.Print "Hello, world!"
End If
state = state + 1
If (state >= 1000) Then
state = 0
End If
Call Sleep(1)
End Sub
Sub myPostInit()
Call PutPin(pin, pinState)
Debug.Print
End Sub
thanks don - your program pulses A.2 which is the led, and this appears to equate to D4 on mini Nodemcu.
I suspect the issue is pin assignments. The compiler does not allow d.1 so I'm a bit unsure how to reference the pins. I've bee trying the Arduino raw in assignments with no luck and other combination but I've not been able to make any other pins work as yet.
As you may have deduced, A.0 through A.15 correspond to GPIO0 through GPIO15, respectively. Some of those pins have dedicated functions, such as GPIO1 being TxD, GPIO3 as RxD, etc. Some of the GPIO pins are dedicated to reading/writing the external Flash memory and can't be used for general purpose I/O.
Further, in ZBasic, the numeric pin values 1-16 correspond to A.0 through A.15. This is all summarized in a table in the ESP8266 ZBasic document:
FFMan wrote:is there a way to reference the adc. It doesn't appear to have a GPIOnn designation that i can see.
In the implementation, the pin number passed to the function implementing GetADC() is ignored for the ESP8266 since there is only one ADC channel. Consequently, you can use any pin number (even zero) and it will produce the same result.
However, I noticed that the compile will generate a warning when the pin number is known at compile time since none of the pins is designated as being an analog pin. You can either just ignore the warning that is generated or you can suppress it thus: