21 Sept 2019
This session we will introduce teh world of IoT through the Arduino, using the MXChip. We will cover the basics of interacting with, and programming the hardware and some basics around Azure and IoT Central.
To install and configure your system you need the following software installed: Ardiuno and VSCode
- After they have been installed, open up VSCode and install the Arduino extension
- Then install the Azure IoT Tools
- Configure VSCode Settings:
In VSCode, click File > Preferences > Settings and then search for "Arduino"
- For Arduino.Path enter the install location of the Arduino IDE
- Then select "Edit in settings.json" under the "Additional Paths". This will open up JSON settings. Make sure that the path to the mxchip board definitions are included. It should look something like this:
"arduino.path": "C:\\Program Files (x86)\\Arduino", "arduino.additionalUrls": [ "https://raw.githubusercontent.com/VSChina/azureiotdevkit_tools/master/package_azureboard_index.json" ], - Close and re-open VSCode
- Press "F1" and select "Arduino: Board Manager"
This HOL you are going to program the MXChip with the IoT equivalent of "hello world".
- Create a new folder and open it in VSCode
- Create a new file "Blinky.ino" and open it in VSCode
- Copy and paste the following code:
//Include required libraries
#include "RGB_LED.h"
//define globals and constants
RGB_LED rgbLed;
uint8_t color[][3] = {
{255, 0, 0}, // red
{0, 255, 0}, // green
{0, 0, 255}, // blue
{0, 0, 0},
{255, 255, 0},
{0, 255, 255},
{255, 0, 255},
{255, 255, 255}
};
//Used to configure the environment assign resources
void setup(){
}
//Programming loop. Executes and performs the actions required
void loop(){
for(int i = 0; i< 8; ++i)
{
Serial.printf("Red: %d, Green: %d, Blue: %d\n", color[i][0], color[i][1], color[i][2]);
rgbLed.setColor(color[i][0], color[i][1], color[i][2]);
delay(1000);
}
Serial.println("Turn off");
rgbLed.turnOff();
delay(1000);
}- Plug the MXCHip board using the USB cable into a USB port on your PC
- You should notice a VSCode recognises it and brings up an information / sample page
- Click the "Compile" button (you will find it on the top left of VSCode, the button with the small check mark on it
)
- In the output window you will notice a compile has started. It should complete without any issues
- When it has completed successfully, press the upload button (
) to deploy the code to the device. You should notice, when the upload has completed the RGB Led starts flashing different colours


