Last time I wrote about getting started with the AZ3166 device – just a brief introduction to the on-board sensors and outputs, and I also wrote a simple application to demonstrate how to turn the red, green and blue LEDs on and off.

In that application, I mentioned that we can control the on/off status of the LEDs by writing a high or low value to three of the digital pins on the device. The numbers that I wrote digital values to were:

  • Red LED – Arduino pin 20
  • Green LED – Arduino pin 19
  • Blue LED – Arduino pin 39

WP_20171015_19_27_55_Pro

The photo above shows a Kitronik edge connector – but you can see that the number of pins only goes up to 16. So there was a mystery here – how is it that we switch the blue LED on in the Arduino code by accessing pin 39, when there aren’t actually 39 pins on the device?

Of course the answer is that the Arduino pin numbers don’t correspond to physical pins on the device – I prefer to think of them as virtual pins. I wasn’t able to find anyone else’s research on how to map physical pin numbers to Arduino virtual pin numbers, so I’ve mapped them out in the table below.

I’ve combined data from the official pin breakout notes on GitHub and some of my own research.

AZ3166 Edge Connector

So if I want to switch on the User LED, I need to change the status of physical pin 8 (i.e. pin 8 on the Kitronik connector). And if I want to access this pin through the Arduino IDE, I need to change the status of virtual pin 45 in the Arduino IDE.

int PIN_8 = 45;
 
void setup() {
  // initialize the pins as digital output.
  pinMode(PIN_8, OUTPUT);
 
}
 
void loop() {
  // turn user LED on
  digitalWrite(PIN_8, HIGH);
  delay(1000);

  // turn user LED off
  digitalWrite(PIN_8, LOW);
  delay(1000);
}

So with the table above, we can access the all the physical digital pins on the AZ3166 MXChip device with virtual pins numbers in Arduino code.

But what about analog I/O? Next time I’ll write about measuring external analog voltages using the AZ3166 device.


About me: I regularly post about Microsoft technologies – if you’re interested, please follow me on Twitter, or have a look at my previous posts here. Thanks!

5 thoughts on “Programming the AZ3166 MXChip Azure DevKit – mapping virtual Arduino pins to physical digital I/O pins

  1. I am actually interested in your post about DocuSign and MVC, but couldn’t find a way to leave a reply on that one.
    I am currently using an old DocuSign NuGet package and upgrading to their newer eSign code set. I am having trouble figuring out simple authentication and wondered if you might be able to give me some direction. It looks to me like you are sending login information in the header of the post which makes sense, However I have read that they want you to use a JWT to get an access token and then use that to get the base URI. Man that seems like a lot to just create an envelope and send it to someone.
    If you have a few mins to help out, I can be reached at vere@motiongrid.com. Totally understand if you are busy or have moved on from MVC. Thanks.

    1. Hi Vere – thank you for your comment. I don’t think I can help with this right now, but I know that DocuSign are active on Twitter, and they might be able to point you to a tutorial which could help.

Comments are closed.