Wokwi Simulations for Arduino Built-In Examples

This thread contains links to Wokwi simulations for some of the Arduino Built-In Examples The built-in examples are available within the IDE under the File/Examples/ tab.

Basics

Digital

Analog

Communication

Control Structures

Sensors

Non-Arduino Serial communication simulations:

Serial Input Basics by @Robin2

  • Example 1 -- Receiving single characters.
  • Example 2 -- Receive several chars with an end marker.
  • Example 3 -- Receive with start- and end-markers
  • Example 4 -- Receiving a single number from the Serial Monitor
  • Example 5 -- Receiving and parsing several pieces of data
  • Example 6 -- Program to receive binary data

How to process incoming serial data without blocking by @nickgammon

Misc

======

The list is an incomplete version of Arduino Built-In Examples. I think it is useful for folks that can't be bothered to wire up an example, or for folks without hardware, so they can examine the behavior of a tested working example. It might also help folks explain how one, can, for example, use the basic analog and LED examples to handle their very special devices that provide or consume digital or analog outputs.

If you know of, or want to build other simulations of the Arduino Built-In Examples, please point them out and I'll add them to this list.

If you want to discuss the dangers, failings, obvious improvements and next steps, or finer points of a particular built-in example, please start a separate forum thread for it along the lines of How to Wire and Program a Button or State Change Detection (Edge Detection) for pushbuttons and I can add that discuss to this list.

6 Likes

This one is easy to achieve with wokwi


you got the tutorial link wrong on that one

the tutorial link is https://docs.arduino.cc/built-in-examples/digital/toneKeyboard/

(which could be achieved in wokwi using wokwi-slide-potentiometer instead of the force sensor).

1 Like

Thanks. Added the Play a Melody and a toneKeyboard one. And also fixed the tutorial link.

I added a few Serial Communication simulations. However several of them depend on connecting to Processing and receiving binary bytes.

Yes wokwi gets limited when it comes to interfacing with a second device (two arduinos or arduino to computer)

To simulate some second device IO, I tried using a hack of the Wokwi Custom Chip UART API page's ROT13 example with a Mega here:

But it seems to drop random bytes:

Other Libraries might be interesting. Here are some stepper motor control library example simulations:

Stepper.h

Examples

MobaTools MobaStepper

This library moves steppers with acceleration in the background, and supplies a lot of other functionality (Servos, Buttons, LEDs, timers)

Simulations

AccelStepper

This non-blocking library uses a smooth acceleration scheme to move steppers.

Examples

  • AFMotor_ConstantSpeed
  • AFMotor_MultiStepper
  • Blocking
  • Bounce -- Simulation: Bounces +/-500 steps
  • ConstantSpeed
  • DualMotorShield -- Simulation: two steppers bounce back and forth at different speeds.
  • MotorShield
  • MultiStepper -- Simulation: two steppers in coordinated motion to multiple positions (no acceleration)
  • MultipleSteppers -- Simulation: Three steppers with acceleration
  • Overshoot -- Simulation: Demonstrate overshooting past 300 and smoothly returning to 0.
  • ProportionalControl -- Simulation: Follow potentiometer position with acceleration.
  • Quickstop -- Simulation: Accelerate towards +/- 500 but stop ASAP after +300&0 subject to acceleration limits. (With an improved simulation)
  • Random -- Simulation: accelerate to random positions with random speeds and accelerations.

FastAccelStepper

Examples

Servo

Examples

  • Knob -- Simulation: Servo motion follows the movement of a potentiometer knob.
  • Sweep -- Simulation: Servo sweeps back and forth at controlled speeds without intervention.

Thank you for posting this.

1 Like

Here's a couple simulations for the Arduino_PID_Library

Simulations: