B4R Question Code Works on Arduino Uno....but not in ESP8266 12E...SERIAL RECEIVE

Discussion in 'B4R Questions' started by embedded, Aug 26, 2018.

  1. embedded

    embedded Member Licensed User

    #Region Project Attributes
    #AutoFlushLogs: True
    #CheckArrayBounds: True
    #StackBufferSize: 300
    #End Region
    Sub Process_Globals
    Public Serial1 As Serial
    Private astream As AsyncStreams
    Dim RECEIVE(10) As Byte
    Private PIN2 As Pin
    Private PIN4 As Pin
    Private PIN5 As Pin
    Private PIN6 As Pin
    Private WIFI As ESP8266WiFi
    End Sub
    Private Sub AppStart
    Serial1.Initialize(115200)
    Log("AppStart")
    astream.Initialize(Serial1.Stream, "Astream_NewData", "Astream_Error")
    RECEIVE(0)=65
    RECEIVE(1)=66
    RECEIVE(2)=67
    RECEIVE(3)=68
    RECEIVE(4)=69
    RECEIVE(5)=70
    RECEIVE(6)=71
    RECEIVE(7)=72
    RECEIVE(8)=73
    RECEIVE(9)=74
    PIN2.Initialize(2,PIN2.MODE_OUTPUT)
    PIN4.Initialize(4,PIN4.MODE_INPUT)
    PIN5.Initialize(5,PIN4.MODE_INPUT)
    PIN6.Initialize(6,PIN4.MODE_INPUT)
    'AddLooper("Looper1")
    WIFI.Disconnect

    End Sub
    Sub Astream_NewData (Buffer() As Byte)
    Log("Received: ", Buffer)
    If Buffer(0) =RECEIVE(0) And Buffer(0)=RECEIVE(0) And Buffer(0)=RECEIVE(0) And Buffer(0)=RECEIVE(0) Then
    Log("COMMAND ONE RECEIVED")
    PIN2.DigitalWrite(True)
    Else If Buffer(0) =RECEIVE(1) And Buffer(0)=RECEIVE(1) And Buffer(0)=RECEIVE(1) And Buffer(0)=RECEIVE(1) Then
    Log("COMMAND TWO RECEIVED")
    PIN2.DigitalWrite(False)
    Else If Buffer(0) =RECEIVE(2) And Buffer(0)=RECEIVE(2) And Buffer(0)=RECEIVE(2) And Buffer(0)=RECEIVE(2) Then
    Log("COMMAND THREE RECEIVED")
    Else If Buffer(0) =RECEIVE(3) And Buffer(0)=RECEIVE(3) And Buffer(0)=RECEIVE(3) And Buffer(0)=RECEIVE(3) Then
    Log("COMMAND FOUR RECEIVED")
    End If
    End Sub
    Sub AStream_Error
    Log("error")
    End Sub
     
  2. embedded

    embedded Member Licensed User

    Solved....PIN6 is not available in ESP8266 12E...After removing problem was solved...
     
    Peter Simpson likes this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice