none
Serial communication and Access forms RRS feed

  • Question

  • Hi!

    I'm having an issue regarding regarding serial communication and vb coding (notice I'm a newbie).

    I'm receiving serial info from Arduino in a COM port. This info can be 0, 1 and eventually a different large combination of numbers and letters.

    So the serial monitor looks something like this.

    1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-0-0-0-0-0-0-0-0-1-1-1-1-1-1-1-1-1-1-5859AK48K6-1-1-1-1-1-1-1-1 etc... (every "-" being a line between characters)

    1) In raw english what I would like to do is:

    If "I get something different (xxxxxxxx) from SerialMonitor" Then

    "Open a determined Access form in the (xxxxxxxx) register/Run a macro doing so"
    "And sleep for 2 secs (don't do anything even if it gets 1, 0, or xxxxxxxx"

    ElseIf "I get a 0 from SerialPort" Then

    "Open a determined Access form/run a macro doing so and play a .mp3 file" Then

    ElseIf "I get 1 from SerialPort" Then

    "Open a determined Access form/run a macro doing so"

    End If



    The thing which I think is the most difficult of this is that having a baud rate of 9600 or higher, everytime it reads serial in the Main() sub, if has more than 1 character/input.

    So everytime it reads, it is like
    1
    1
    1
    1
    1
    xxxxxxxx
    0
    0
    0
    1
    1
    1
    1
    1

    Therefore, having this kind of 'blocks' I need it not to read the first 0/1/xxxxxxxx, but to see if it contains those things in the previous order so:

    if "it contains xxxxx" then
    ...
    elseif "it cointains 0" then
    ...
    elseif "it contains 1" then
    ...
    end if



    2) The other question is that ideally, depending on what the xxxxxxxx is, it should open one form or other.
    So if in an Access table/CSV file, xxxxxxx read corresponds to a True/1/Yes value, it should open an A form in that register. And if in that table, xxxxxxxx read corresponds to a False/No/0 value, it should open a B form in that register, and play a mp3 file. (This 0 and 1 ar not related to the serial com input)


    I hope you can help me with this.

    Every answer will help a lot. regarding the serial com, the access part or if you could think of an easier way to do this.

    Thanks in advance!!
    Friday, March 1, 2019 4:22 PM

All replies

  • Hi,

    I don't really understand what you mean,Do you want to make judgments in the Arduino code?

        If Serial.available() > 0 Then
                receiveVal = Serial.read()
    
                If receiveVal = "1" Then
                    ...
                Else If receiveVal = "0" Then
                    ...
                Else
                    ...
                End If
            End If

    Arduino:

    https://www.arduino.cc/reference/en/language/functions/communication/serial/

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, March 4, 2019 5:58 AM