B4R Question Wemos dont work Trafic light example

Tayfur

Well-Known Member
Licensed User
Longtime User
Hello;
This first try for hardware test.

I want to try examples.
TrafficLight.b4r

So I cant run it
B4R version: 1.20
Parsing code. (0.00s)
Compiling code. (0.07s)
Building project (0.05s)
Compiling & deploying Ino project (WeMos D1 R2 & mini - COM3) Error

In file included from sketch\B4RDefines.h:23:0,
from sketch\b4r_main.cpp:1:
sketch\b4r_main.cpp: In static member function 'static void b4r_main::_appstart()':
rCore.h:638: error: 'A5' was not declared in this scope
#define /*Byte A5;*/ Pin_A5 A5
^
sketch\b4r_main.cpp:29:34: note: in expansion of macro 'Pin_A5'
b4r_main::_pinbutton->Initialize(Pin_A5,Pin_MODE_INPUT_PULLUP);
^
exit status 1
'A5' was not declared in this scope

B4X:
#Region Project Attributes
    #AutoFlushLogs: True
    #CheckArrayBounds: True
    #StackBufferSize: 300
#End Region

Sub Process_Globals
    Public Serial1 As Serial
   
    Public pinButton As Pin            'pin for the button
    Public pinLEDGreen, pinLEDYellow, pinLEDRed As Pin         'pins for the Leds
    Public TimerGreenRed As Timer
    Public LightOn = False As Boolean
    Public LightGreen = False As Boolean
    Private BounceTime As ULong
    Private BounceDelay = 10 As ULong
End Sub

Private Sub AppStart
    Serial1.Initialize(115200)

    TimerGreenRed.Initialize("TimerGreenRed_Tick", 2000)
'    TimerYellow.Initialize("TimerYellow_Tick", 500)
   
    'Using the internal pull up resistor to prevent the pin from floating.
    pinButton.Initialize(pinButton.A5, pinButton.MODE_INPUT_PULLUP)
    pinButton.AddListener("pinButton_StateChanged")

    pinLEDGreen.Initialize(7, pinLEDGreen.MODE_OUTPUT)
    pinLEDYellow.Initialize(8, pinLEDYellow.MODE_OUTPUT)
    pinLEDRed.Initialize(9, pinLEDRed.MODE_OUTPUT)
End Sub

Private Sub pinButton_StateChanged (State As Boolean)
'    Log("State: ", State)                            'Log the State value

    If State = False Then                            'if State = False
        If Millis - BounceTime < BounceDelay Then
            Return
        Else       
            pinLEDRed.DigitalWrite(True)        'switch ON the red LED   
            LightOn = Not(LightOn)                    'change the value of LightOn
            BounceTime = Millis
'            Log("Light: ", LightOn)                    'Log the LightOn value

            TimerGreenRed.Enabled = LightOn        'enable TimerGreenRed Timer
           
            If LightOn = False Then                        'if LightOn = False
                pinLEDGreen.DigitalWrite(False)    'switch OFF LED Green
                pinLEDYellow.DigitalWrite(False)    'switch OFF LED Yellow
                pinLEDRed.DigitalWrite(False)        'switch OFF LED Red
            End If
        End If
    End If
End Sub

Private Sub TimerGreenRed_Tick
    If LightGreen = True Then                    'if LightGreen = True
'        Log("TimerGreenRed_Tick LightYellow") 'write the Log
        CallSubPlus("EndYellow", 500, 0)
        pinLEDGreen.DigitalWrite(False)    'switch OFF LED Green
        pinLEDYellow.DigitalWrite(True)    'switch ON LED Yellow
        LightGreen = False                            'set LightGreen to False
    Else
'        Log("TimerGreenRed_Tick LightGreen") 'write the Log
        pinLEDRed.DigitalWrite(False)        'switch OFF LED Red
        pinLEDGreen.DigitalWrite(True)    'switch ON LED Green
        LightGreen = True                                'set LightGreen to True
    End If
End Sub

Private Sub EndYellow(Tag As Byte)
'    Log("TimerYellow_Tick LightRed")    'write the Log
'    Log(" ")
    pinLEDYellow.DigitalWrite(False)    'switch OFF LED Yellow
    pinLEDRed.DigitalWrite(True)            'switch ON LED Red   
End Sub

Onether issue;
I tried pins out voltage; And I cheked Voltmeter.
its not change it
 
Top