Using Arduino IDE and Simuli Virtual Lab for Arduino

First, let's open Arduino IDE and get familiar with the User Interface.

First is the Menu bar where you will find a lot of the options like saving sketches, library manager and other options grouped in categories. Then we have the Tool bar which has buttons for compiling the code and uploading it to the microcontroller. It also has buttons for creating, saving and opening sketches along with a button to open the Serial Monitor.

The Arduino IDE has a code editor built-in where you write the sketches for your project. It has syntax highlighting to make it easier to understand the code. The code for the Arduino platform is primarily divided into a setup and loop. The setup part runs at startup and has all the required configurations. The loop part of the code has the functionality of the program and it keeps running in loop after the setup.

The code for the project is given below, you can paste this code into the Arduino IDE.

// the setup function runs once when you press reset or power the board
void setup() {
  pinMode(10, OUTPUT);

// the loop function runs over and over again forever
void loop() {
  digitalWrite(10, HIGH);   // turn the LED on (HIGH is the voltage level)
  Serial.println("Hello IoTIFY"); //prints Hello IoTIFY every time the LED turns on
  delay(1000);                       // wait for a second
  digitalWrite(10, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);                       // wait for a second

Now we need to get the Compiled Binary for this code.

Compiled binary is basically the code which the machine understands. Before we can export the compiled binary, we need to save this sketch. Navigate to File in the Menu bar and then click on save. Navigate to where you want to save the sketch, name it Blink and click on save .Now we are ready to export the compiled binary. Go to Sketch and select Export Compiled Binary. Wait for a few seconds as the IDE compiles our code. Once we have exported these binaries, we can now use this in our IoTIFY Virtual Lab project.

Navigate to the folder where we had stored the sketch in the last step. Here we will find a file called Blink.ino.standard.hex. Keep this file handy and go to Simuli Virtual Lab.

If you are using an example code, you need to first save the code before exporting the compiled binaries, since the example codes are saved as read-only.

Running the project in Simuli

Now we will head back to Simuli Virtual Lab. Here we will find a list of the projects that are currently running, among them, our project named "blink" should be ready. Click on the Open button to fire up the instance and start working with the project.

A new tab with our workspace should open up. Here, we see the Arduino Uno board, a Terminal for communicating with the Arduino, an interface to interact with the individual pins and any sensors that we may have added.

Now we will upload the compiled binary for our project that we had exported from Arduino IDE in the last step. Click on the Arduino Uno board, this will open up a File Explorer window. Navigate to the folder where we had saved the blink sketch and we will see the Blink.ino.standard.hexfile. Select this hex file and click on Open. Alternatively, if you already have the folder with the hex file open, you can also drag and drop the hex file onto the Arduino board.

Once we have uploaded the hex file, we now need to reset the Arduino. For this just click on the red power button at the top left of the Arduino. Give it a few seconds and once the board resets, you will see the LED at pin 10 is blinking and a "Hello IoTIFY" message is displayed each time the LED turns on.

Congrats, you have just completed your first project based on Arduino.

Last updated