Getting to grips with Firmata

userHead cyrillicsoft 2019-01-14 02:21:41 1721 Views0 Replies
Hi all!
So I've been playing around with the C# blinkYourBoard LattePanda example, trying to get a feel for the Arduino communication tools available.
After a while, I ended up with some questions which I can't find good answers to, so I would be very thankful if someone here could clarify some things for me.

As I said, I've got a simple set-up that "blinks" the D12 pin.
I've been trying to understand some of the code in Arduino.cs

The first question(s): in the Open() function of the class, what exactly do the REPORT_ANALOG and REPORT_DIGITAL commands do? The official Firmata documentation on GitHub doesn't really explain it and it feels like it should be obvious... Why does it use the word "port" when talking about digital communication, and "pin" when talking about analog communication?

The second question(s): why does the Open() function report 6 analog pins and 2 digital ports? What is the significance of these numbers? How do I know what DIGITAL pins the 2 digital ports contain? What exactly is a port in this context? Just a set of pins? Or is there something more to it?

The third question(s): what is up with the 0xF5 command (set digital pin value)? The digitalWrite function uses the pin argument to determine the port number and sets a bit in the ports array. It then sends a digital I/O message (0x90) with the port and its pin values. But why don't we use 0xF5?
I tried to swap the code to send a 0xF5 message like so: byte 0 = 0xF5, byte 1 = pin_function_argument, byte 2 = value_function_argument
But when I ran the code, my LED didn't blink...
In what situation would the 0xF5 command be usable?