Help wanted for blinking led with ESP8266

Discussion of issues related to writing ZBasic applications for targets other than ZX devices, i.e. generic targets.
Post Reply
memi205
Posts: 6
Joined: 03 May 2018, 16:41 PM

Help wanted for blinking led with ESP8266

Post by memi205 »

Hi !
I'm beginning with ZBasic and I want some help for my first program.
I'm using a Wemos D1 mini (ESP8266)
I wrote this simple program to blink a led with the D4 (GPIO2) pin :

Code: Select all

Sub Main()
   Dim i as Integer, j as Integer
   For j = 1 to 32000
      PinHigh(2)
      For i = 1 to 1000 
      Next i
      PinLow(2)
      For i = 1 to 1000 
      Next i
   Next j
End Sub
So, I had this error message :

led.c: In function 'zf_Main':
led.c:110:3: error: 'ESP_PIN_OUT_SET' undeclared (first use in this function)
ESP_PIN_OUT_SET = 0x0002;
^
led.c:110:3: note: each undeclared identifier is reported only once for each function it appears in
led.c:114:3: error: 'ESP_PIN_OUT_CLEAR' undeclared (first use in this function)
ESP_PIN_OUT_CLEAR = 0x0002;
^

Can you help me ?

Thank's !
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Re: Help wanted for blinking led with ESP8266

Post by dkinzer »

memi205 wrote:I had this error message
I'm not quite sure yet how the circumstances arose that lead to the error but I can help you work around it for now.

In the ZBasic installation directory open the directory zlib and load the file zbasic.h found there into an editor. Search for a line beginning with #define IO_MUX_GPIO10 and after it insert the following lines:

Code: Select all

#define ESP_PIN_DIR_OUTPUT              GPIO_DIR_OUT
#define ESP_PIN_DIR_INPUT               GPIO_DIR_IN
#define ESP_PIN_OUT_SET                 GPIO_OUT_SET
#define ESP_PIN_OUT_CLEAR               GPIO_OUT_CLR
#define ESP_PIN_OUT                     GPIO_OUT
#define ESP_PIN_IN                      GPIO_IN
Save the file with the changes and then try re-compiling your ZBasic project.
- Don Kinzer
memi205
Posts: 6
Joined: 03 May 2018, 16:41 PM

Post by memi205 »

Thank's for your answer.

I just found the problem, The pin 2 must be named A.2 on the ESP8266.

So, my test program (very simplified) is now like this :

Const pin2 as Byte = A.2
Sub Main()
Do
Call PutPin(pin2,0)
Call Delay(1.0)
Call PutPin(pin2,1)
Call Delay(1.0)
Loop
End Sub

Thank's !
Post Reply