Blinky Program - Mango-kid/maciot GitHub Wiki
Once you have the software installed you can open it up and we will configure the interface so you can program the board. Once the software is open the first step is to configure Arduino so it knows what board we are using. The following values will need to be set in the Tools menu.
You may have a different port label than ttyACM0 you may have something that looks like COM12. If there is more than one you can determine through trial and error or using (Windows: Device Manager) or (Linux: dmesg).
Now in the programming field we need the following code. Take a look at the comments in the code to gain a better understanding of how the program is operating. Dont just upload the code right away you wont learn anything. Instead take a look at the code and see if you can tell what it is doing.
/* the setup function is called once on startup */
void setup() {
pinMode(SWITCH0, INPUT_PULLUP); // set the switch to an input with pullup
pinMode(LED0, OUTPUT); // set LED0 to an output
}
/* Everything in this loop is done forever */
void loop() {
int sensorVal = digitalRead(SWITCH0); // read the switch and write to sensorVal
if (sensorVal == HIGH) { // check the switch state and turn the LED on or off.
digitalWrite(LED0, LOW);
} else {
digitalWrite(LED0, HIGH);
}
}
Click the check-mark in Arduino to see if your program compiles. If it doesn't take a look at the errors in the red section at the bottom. If you don't understand the error maybe Google it.
Programming the Board
Once we have type verified that the code will compile we need to load it on the board. To do this we have to make sure the board is connected and that our Arduino is configured as described above.
Putting the Board in Program Mode
To put the board in program mode we must push both the enable and flash buttons at the same time and hold them down. Now release the enable button and then release the flash button. The controller it now in program mode
Now click the upload button in Arduino and the code will be loaded on to the MacIoT Board. Once the uploading has finished (usually takes about 5 - 10 seconds) press the Enable button to reset the board and the program will start running.