Not shown on the
schematic is an LED that is connected to
the Mini’s Arduino-defined pin 2 (WeMos
D1 Mini D4).
WeMos D1 Mini pin
definitions depend on the
platform you are using.
B4R incorporates a library that defines
all of the D1 Mini pins for use in a B4R
program. The universal pin definitions for
the Mini are shown in Screenshot 3. As
you can see, the Mini pin definitions
depend on the platform you are using. The
B4R rESP8266 library definitions for the
D1 Mini can be seen in Screenshot 4. In
addition to ESP8266 I/O pin control, B4R
is also supported by another library that
enables the ESP8266’s Wi-Fi engine. The
members of the ESP8266WiFi library are
displayed in Screenshot 5.
Blinking with B4R
56 August 2017
Since the Mini needs a serial connection for
programming, we must declare a Serial
object in our B4R code. As you can see,
we spawned a Serial object and called it
Serial1. Using Serial1, we can call upon all
of the members and methods associated
with the Serial object.
We’ll be blinking the WeMos Mini
LED at a steady rate. To do that, we need
to bring a timer into play. So, again we
declare and spawn an object. This time
it’s a Timer object and we’ll call it Timer1.
Our LED blinker code is not using
either of the ESP8266 libraries we
previously examined. So, the Pin object is
not official B4R. It leans more to the
Arduino side of the fence. However, it
works because B4R has access to the
Arduino resources via the Arduino IDE
we installed earlier.
Now that the objects in the
Process_Globals subroutine are set up,
we’ll need to initialize them. As with any
other programming language, we should
■ SCREENSHOT 3. The
duties are performed by a
pair of transistors in
conjunction with the
modem control signals.
Coding B4R applications is very
similar to coding a VB6 application as B4R is event driven.
Let’s walk through a simple B4R program that blinks the
LED attached to the WeMos Mini’s I/O pin D4:
Power for the D1 Mini is
provided by the ME6211
voltage regulator and
associated filter capacitors.
‘‘‘‘‘‘‘‘These global variables will be declared
‘‘‘‘‘‘‘‘once when the application starts.
‘‘‘‘‘‘‘‘Public variables can be accessed from
Public Serial1 As Serial
Private Timer1 As Timer
Private pin2 As Pin
■ SCREENSHOT 5.
The members of
this library allow us
to use B4R to
■ SCREENSHOT 4. This is
a screen capture of the B4R
library definitions of the
WeMos D1 Mini pins. We
can also use this library to
programmatically reset the
WeMos D1 Mini’s ESP8266.