Introduction: How to Run/test Your Arduino Code Online for Free?

There are various options to run Arduino code online. Which is the best depends on how useful it is to the user's specific use case. there can not be one scale to measure the performance of all such Arduino simulation options. Some are free, some are paid, some are up to date and some are outdated, some have good options and some have poor. So, I cannot quantise. Let us start with my preferred approach, Wokwi Arduino Simulator πŸ‘‰πŸ‘‰

Step 1: No Installations No Downloads! - Open a Browser

Open any browser. Currently, all the browsers support the Arduino simulation code execution.

In this tutorial, I will use either firefox or Avast secure browser. I have not seen any significant differences in the performance of the Arduino simulator.

Before we start,

  1. The Arduino code running online or on a simulator may not guarantee the same performance of behaviour when it comes to real hardware
  2. The real hardware poses you more challenges (open connections, short connections, missing connections, pullups, noise, floating pins, dry solder, poor solder, incompatible voltage, insufficient setup and hold times, ringing etc
  3. Software simulations are just the steps to learn but it is not the final destination

A request:

Please comment and like this project, if you find this helpful. Also, feel free to ask questions or suggest any new topics. I will be glad to reply and improve πŸ˜€

Let us begin :)

Step 2: How to Test the Arduino LED Blink Code Online?

LED blink code is the basic example which most of us would have run when exploring hardware circuitry involving an MCU. This is definitely equivalent to the "Hello World" program in computer languages πŸ˜€. In this step, we will see how we can test our basic LED blinking code for Arduino

To verify the LED code online, please visit

https://wokwi.com/playground/blink

The view is something like the image shown (might be slightly outdated) πŸ˜…

the Right pane is where we will put the code :)

Let us try a few LED blink examples:

Code 1 below:

______________________________

/*<br>  Blink   Turns on an LED for one second, then off for half a second, repeatedly.  

   This example code is in the public domain.  */ 

  // Pin 13 has an LED connected on most Arduino boards. // give it a name: 

int led = 13;
// the setup routine runs once when you press reset:

void setup() {                   // initialize the digital pin as an output.   
pinMode(led, OUTPUT);      
}
// the loop routine runs over and over again forever: 

void loop() 

{   
digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)   
delay(500);               // wait for a second   
digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW   
delay(500);               // wait for a second 
}

________________________________

once I copy the code and paste it in the link above, I could run and test my Arduino code online πŸ˜€

Please let me know if you have any trouble in running the LED code in the Link above. Next, we will see the servo motor code!!!

Step 3: How to Test Your Arduino Servo Motor Code Online?

Servo Motors are intelligent motors which can understand the angle of rotation based on the PWM width we drive with. They have built-in comparators which compared the width of the PWM and then act accordingly. They are used in robotics, pick and place and many such examples. These are definitely of interest to hobbyists. In this step, we can see how one can play with Arduino Servo motor simulations as well as test their own code online for free πŸ˜ƒ

  • Go to

https://wokwi.com/playground/servo

  • Copy the servo motor code you want to test. Let me also take a random code from the internet

This is the code from

Here is the code from Arduino Stackexchange- just random:

#include  <br>
Servo myservo;  // create servo object to control a servo 
                // a maximum of eight servo objects can be created 
int pos = 0;    // variable to store the servo position 
void setup() 
{ 
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object 
} 
void loop() 
{ 
  for(pos = 0; pos < 90; pos += 1)  // goes from 0 degrees to 180 degrees 
  {                                  // in steps of 1 degree 
    myservo.write(pos);              // tell servo to go to position in variable 'pos' 
    delay(15);                       // waits 15ms for the servo to reach the position 
  } 
  for(pos = 90; pos>=1; pos-=1)     // goes from 180 degrees to 0 degrees 
  {                                
    myservo.write(pos);              // tell servo to go to position in variable 'pos' 
    delay(15);                       // waits 15ms for the servo to reach the position 
  } 
}
  • The copied code is pasted into the editor field of the shared link
  • The RUN code button was pressed.
    • Note that it will take some time to compile one time (in a few seconds). If you stop and rerun it will be instant.
  • Play with the simulations as long as you want.
  • Here is the screenshot of the Arduino Servo motor code in action :)

Please leave a comment if you have any questions.πŸ˜€

Step 4: How to Test Arduino NeoPixel LEDs Online?

NeoPixel LEDs are individually addressable LEDs. Only one data line is connected to all the LEDs. All the LEDs in the strip are connected in series. Each LED will have a small logic IC which will understand the incoming data, process it and light up the RGB LEDs accordingly. It is quite a fascinating idea which is now a globally called FastLEDs or NeoPixel LEDs, but basically, all these are individually addressable LEDs.

<ul><li>Copy the code of your NeoPixel project. <li>Make a note of the number of LEDs and number of the Arduino pin to which the data line of the LED is connected to <li>I will also pick a random example from the internet<li>I choose <a href="https://learn.adafruit.com/a-neopixel-blinkendisc/arduino-code" rel="nofollow">adafruit link</a> to take a sample code for our test<li>I changed the pin number of Arduino from 0 (from the code) to 6.<li>I changed the number of LEDs from 24 to 8<li>Below is the screenshot of the running simulation in action πŸ˜€πŸ˜€πŸ˜€</ul><p><strong>Sample code: </strong></p><p><strong><br></strong></p><p>#include <br></p>
#define NUM_LEDS              24 // 24 LED NeoPixel ring
#define NEOPIXEL_PIN           0 // Pin D0 on Gemma
#define VIBRATION_PIN          1 // Pin D1 on Gemma
#define ANALOG_RANDOMNESS_PIN A1 // Not connected to anything
#define DEFAULT_FRAME_LEN     60
#define MAX_FRAME_LEN        255
#define MIN_FRAME_LEN          5
#define COOLDOWN_AT         2000
#define DIM_AT              2500
#define BRIGHTNESS_HIGH      128
#define BRIGHTNESS_LOW        32
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUM_LEDS, NEOPIXEL_PIN);
uint32_t color          = pixels.Color(0, 120, 30);
uint8_t  offset         = 0;
uint8_t  frame_len      = DEFAULT_FRAME_LEN;
uint32_t last_vibration = 0;
uint32_t last_frame     = 0;
void setup() {
  // Random number generator is seeded from an unused 'floating'
  // analog input - this helps ensure the random color choices
  // aren't always the same order.
  randomSeed(analogRead(ANALOG_RANDOMNESS_PIN));
  // Enable pullup on vibration switch pin.  When the switch
  // is activated, it's pulled to ground (LOW).
  pinMode(VIBRATION_PIN, INPUT_PULLUP);
  pixels.begin();
}
void loop() {
  uint32_t t;
  // Compare millis() against lastFrame time to keep frame-to-frame
  // animation timing consistent.  Use this idle time to check the
  // vibration switch for activity.
  while(((t = millis()) - last_frame) <= frame_len) {
    if(!digitalRead(VIBRATION_PIN)) { // Vibration sensor activated?
      color = pixels.Color(           // Pick a random RGB color
        random(256), // red
        random(256), // green
        random(256)  // blue
      );
      frame_len = DEFAULT_FRAME_LEN; // Reset frame timing to default
      last_vibration = t;            // Save last vibration time
    }
  }
  // Stretch out frames if nothing has happened in a couple of seconds:
  if((t - last_vibration) > COOLDOWN_AT) {
    if(++frame_len > MAX_FRAME_LEN) frame_len = MIN_FRAME_LEN;
  }
  // If we haven't registered a vibration in DIM_AT ms, go dim:
  if((t - last_vibration) > DIM_AT) {
    pixels.setBrightness(BRIGHTNESS_LOW);
  } else {
    pixels.setBrightness(BRIGHTNESS_HIGH);
  }
  // Erase previous pixels and light new ones:
  pixels.clear();
  for(int i=0; i
  pixels.show();
  // Increase pixel offset until it hits 6, then roll back to 0:
  if(++offset == 6) offset = 0;
  last_frame = t;
}

Please leave a comment if you have any questions

It is possible to change the number of LEDs to 24 or any number you want

It is possible to also change the Arduino pin number to which the LED data line is connected to

Please leave a comment if you have any questions

In the coming days, there will be an updated user interface where it will be even more fun to play with the simulations πŸ™‚

Let us see how to test your LCD code online in the next steps

Step 5: How to Test Your SSD1306 OLED Arduino Code Display

The OLEDs are great. They lit really well. They don't consume any power when the display is minimal. They can be read in an outdoor environment as well. They make a great HMI value addition for any projects. We can display text, number, graphics and stories on it. It is indeed a good tool and skill to have it. Let us ee how to get the OLED Arduino code online here πŸ‘‡

  • Visit https://wokwi.com/playground/ssd1306
  • Copy your code and paste it into the editor field
  • It is usual to have the I2C address of the SSD1306 OLED to have either 0x3D or 0x3C as the address.

I have used the existing code directly present in the link, but I hope it is straight forward to replace the code in the editor contents to swap with the code you want to test

Please ask questions if you have any. Please comment and like if this is useful πŸ˜ƒ

In the next step, I will share how I test the LCD1602 Arduino code online πŸ‘‰

Step 6: How to Test Arduino LCD1602 Code Online?

LCD1602 when I say, I mean LCD display with 16 columns and two rows. It usually comes with a backlight. the background will either be green or blue for most of the cases. The display is there for decades and is still a good low-cost HMI to add to the projects. Advantage of the readability of the display without backlight in sunlight should not be forgotten πŸ‘Œ

  • Delete the prefilled code in the editor window
  • Paste the example code in the editor window
  • There are a few things to take care
    • Contrast settings
    • Backlight
    • data connections can be 4 bit or 8 bit. 4 bit is sufficient enough as we don't have to spend a huge amount fo data
    • I2C connections are also a possibility. As of now, this is for LCD in which I2C lines are connected

Let me choose a random LCD1602 code from the internet for example:

Please leave comments πŸ™ if you have any questions or suggestions

Step 7: Going Forward πŸ‘¨β€πŸ«πŸ‘©β€πŸ’»πŸ‘¨β€πŸš€

  • You might not be able to run the code for a few use cases, but don't worry, this link, for example, shows how much useful the Wokwi Simulator is for you https://wokwi.com/arduino/libraries

other links which might interest you:

https://www.instructables.com/Best-Free-Online-Wok...

https://www.instructables.com/Web-Based-Arduino-Si...

https://www.instructables.com/Online-Arduino-Simul...

https://www.instructables.com/How-to-Simulate-Ardu...

https://www.instructables.com/Famous-Simon-Says-Ga...

https://www.instructables.com/How-to-Runtest-Your-...

We've always defined ourselves by the ability to overcome the impossible. And we count these moments. These moments when we dare to aim higher, to break barriers, to reach for the stars, to make the unknown known. We count these moments as our proudest achievements. But we lost all that. Or perhaps we've just forgotten that we are still pioneers. And we've barely begun. And that our greatest accomplishments cannot be behind us, because our destiny lies above us.