Simulator For Arduino
Simulator For Arduino
Table of contents
Introduction ...................................................................................................... 4
What's new .................................................................................................... 4
Free Version Differences ................................................................................. 5
Simulator or Arduino ...................................................................................... 5
Getting Started .................................................................................................. 6
System requirements ...................................................................................... 6
Getting help .................................................................................................. 6
Using the IDE .................................................................................................... 6
Program Window ........................................................................................... 7
Legend ..................................................................................................... 8
Program Popup Menu ................................................................................. 9
BreakPoint ................................................................................................. 9
Bare Minimum ......................................................................................... 10
Loading a Sketch ...................................................................................... 10
Running a Sketch ..................................................................................... 11
Hidden code ............................................................................................ 11
Variables Area ............................................................................................. 11
Variables Popup Menu .............................................................................. 12
Arduino Area ............................................................................................... 13
Arduino Popup Menu ................................................................................ 13
Menu System ............................................................................................... 14
File Menu ................................................................................................ 14
Run Menu ................................................................................................ 14
View Menu .............................................................................................. 15
Hardware ................................................................................................ 16
Tools ...................................................................................................... 17
Logic Analyzer ..................................................................................... 18
Serial Monitor ...................................................................................... 19
Unit Testing ......................................................................................... 19
Trace ...................................................................................................... 20
Options ................................................................................................... 21
Help ....................................................................................................... 21
Dialog Windows ........................................................................................... 22
Edit Window ............................................................................................ 22
EEPROM Window ..................................................................................... 23
Input/Output Window ............................................................................... 24
Simulation Popup Menu ........................................................................ 25
View Subroutines ..................................................................................... 26
Call Stack ................................................................................................ 26
Class Explorer .......................................................................................... 27
Error Message .......................................................................................... 27
Shortcut Toolbar .......................................................................................... 27
Shortcut keys ............................................................................................... 28
Example Sketches ......................................................................................... 29
Test Sketches ........................................................................................... 29
Language Processing ........................................................................................ 29
Keywords .................................................................................................... 29
2 / 34
3 / 34
30
30
30
31
31
34
Introduction
Simulator for Arduino is an Arduino Simulator which may be downloaded or purchased from
www.virtronics.com.au. The Free version has a ten minute trial, a thirty day trial period (or 300 second until
unlocked) then a 30 second delay on opening sketches and is code limited to 150 lines. The Pro Version
has no limitations.
The benefits and features of an Arduino Simulator are:
Speed up Arduino designs
Try out other Arduino boards first and see the pin-out configurations
Demonstrate a project to a potential customer remotely
The ability to educate and demonstrate the inner workings of an Arduino sketch
Run a sketch without the hardware, or prior to purchasing hardware
Debug a sketch, step through or run with a breakpoint and see the variables change
Find out number overruns such as setting a byte to 256, assigning a new value to a const variable, or
use library routines without including the library
Graphically view L:CD and colour screens
Trace and Error logs
Improved Serial Monitor which allows an interface between the Simulator and the real world
Simple logic analyser to view digital pins graphically
Automated testing (Unit Testing) to check that sketches will provide a certain output
Variable watch which shows only the last variable changed or selected variables
Variable insight which allows for variables values to be viewed by clicking on them in the Sketch
Window (ensure Menu Option is turned on)
Design a new board inside the Simulator using the Hardware > Save Settings and Load Settings items.
Many more features and continuous improvements with regular updates
The SIMFORARDUINO Pro Version license is licenced to one user only for use on up to 3 computers or to
100,1000 or 10000 computers for SiteWide Educational licences at a discount.
Press F1 inside the Simulator to open context sensitive help.
What's new
Version 0.99F - Mar-2014
1. Allow nested arrays test1[test2[0]]
2. Add syntax colours rectangles for different skins
3. Add Serial.readString
4. Improve timer1 interrupt - add all functions
5. Press ms after millis to increment by 1 second or timer1 interrupt when activated
6. Add hint to Millis text showing when next timer1 interrupt is due
7. Allow breakpoint on timer interrupt - ensure current instruction is executed before ISR
8. Add hidden commands to Stimulus file & Allow breakpoints when Stimulus file command run
9. Allow map instuction to run over 4 lines (an any instruction over any number of lines)
10. Fixup Serial Monitor echo only working for println but not print commands
11. Allow Arduino/ Variable sareas to undock and redock using x-axis
12. Add persistent vertical scrollbar to sktehc screen
13. Char array strings only shrink when Char is Selected - Hex no always show hex etc
14. Fixup Tools> Logic Analyzer
4 / 34
Simulator or Arduino
Simulator or Arduino is a good question and Simulator and Arduino or even Arduino and then Simulator is a
good answer. The Simulator was not designed as a replacement for Arduino but an add-on product to the
Arduino development kit and has been designed as a training/demo/debugging tool. It has not been
designed as a development or compiling tool. We fully support the Arduino project and encourage new users
to buy and try a real Arduino kit first and then purchase the Simulator when needed. For first time users,
please refer to the book "Getting Started with Arduino" by Massimo Banzi.
To develop code for Arduino, a good starting point is to use the Arduino Uno together with the Arduino IDE.
5 / 34
For larger projects, the Arduino Mega or Due may be more suitable. This Simulator has not been designed
to check for syntax errors, and we recommend only using the Simulator for debugging only after the Arduino
sketch compiles in the Arduino IDE but there is still some annoyign issue.
Official Arduino kits are recommended since these are well designed and support for the Arduino project
leads to more cool new development boards and IDE upgrades. Please note that the official arduino website
is www.arduino.cc.
Getting Started
Getting Started.
Download the zip file, extract the setup.exe file. When finished, run this program to install the Simulator for
Arduino program and click yes to accept the EULA (End User Licence Agreement). For the Free Version,
there is a ten minute trial period then an unlock process. To Unlock the Simulator, click on the Get Unlock
Key button and then copy the Unlock Key back to the Simulator and clicking Unlock. Please email us if
there are any issues with this process.
System requirements
The System Requirements are a PC Pentium II or later.
The Simulator for Arduino program will run on the following systems:
WINDOWS
Windows
Windows
Windows
Windows
Windows
2000
XP
Vista
7
8 and 8.1
MAC
Windows using Parallels
Windows using VMWare VM systems
LINUX
Wine on Linux (windows emulator)
Untested on Windows 98,ME and 95. If the Simulator does run on any of these systems, please let us know
by sending an email to [email protected]
Getting help
For help, please email [email protected] and please attach the sketch, or click the email button
inside any Error Message. Replies sometimes can take a few weeks.
Also, please make use of the forum (http://forum.virtronics.com.au/) which may be a little quiet sometimes.
There are already many questions and answers on the forum and threads can be subscribed to in order to
be emailed about new replies.
Before emailing, please check that the sketch compiles in the Arduino IDE first.
6 / 34
Note that the order of the Program window, Variables are and Arduino picture may be swapped by Selecting
View|Arduino on Left. The preferred method is to have the Program Window on the left so that the work flow
is input,data and output. The Arduino picture and/or Variables area may be hidden by selecting Options >
Show Arduino and/or SHow Variables and clicking on it to uncheck these options.
When the Simulator for Arduino IDE is resized, the Variables window will disappear first since this is seen
as the least important window. If the main screen is made smaller, the Program window will then disappear
and the Arduino Screen will always be on top. This allows for sketches to be simulated as they would
appear for real. There is also a Minimize button designed for this purpose.
Program Window
The Program window area shows the program listing, and the cursor will always be in the vertical center of
the screen. The Program Window allows for the program to be stepped through. When selected, the
following keys may used to run the program:
F7 key may be used to step through the program and
F8 can be used to step over subroutines while still executing all the code inside the subroutine.
F9 may be used to run the program
Shift F8 may be used to step out of a routine
F2 may be used to force a reset
F3 may be used to open the Find window to search for text
F6 may be used to edit the sketch
See the Shortcut Toolbar for more info on the step and run icons
7 / 34
A new line may be selected by right clicking anywhere in the Program or Sketch window and selecting Set
Next Statement.
The Statusbar shows the Line number, Last Line number and the next code to be executed. If the AutoStep
time is set to less than 2ms, the Status-Bar will not update until Run or AutoStep is stopped.
Special Simulator hidden code may be used to setup a particular hardware configuration, and this allows the
setup configuration to be saved inside the comments of the sketch. See Hidden code for more detail.
Legend
The Legend may be turned on by selecting View | Legend or right clicking onteh Arduino picture and
selecting Legend.
The Legend shows the colours and states of the Digital output. The AnalogWrite value of a digital pin will be
displayed to the left of the digital pin when the analogWrite() routine is used.
8 / 34
View Line Numbers - turn on the line numbers in the Program Window - this is useful for checking
subroutines
Edit Sketch - allows the sketch to be edited in the Edit Window
Syntax Colouring - show comments as light gray, #if hash commands in medium grey, definitions in
green, constants in Olive and subroutines as blue
Match Braces - find the opening or closing bracket for the current line
Tabs On Top - places the tab with the filename at the top if checked or else the bottom
Find - open the Find window to find text inside the sketch
Show Arduino - uncheck to hide the Arduino picture and allow more screen area for your super sketch
Errors Enabled - turn off to prevent any annoying errors, and hope for the best. Please note this must be
manually turned on again to show any sketch errors.
BreakPoint
A breakpoint can be set by right clicking anywhere in the program window.
The pop-up menu has an option which can be clicked to add or clear the breakpoint. Please note that a
breakpoint condition can be added in the Edit Window to only break at the red line on a certain condition
such as when a variable is above a certain level such as i>=17.
9 / 34
If a BreakPoint is added, the breakpoint line will be shown in red. This is commonly used with the AutoStep
or F9 command. The breakpoint can also be saved inside a comment using Hidden Code
the syntax
// breakpoint(20)
will set a breakpoint on line 20. If a breakpoint is set on a new line, the previous breakpoint will be cleared.
To turn off a breakpoint, select the same line and select Breakpoint.
Left click on a set Breakpoint to find out which number it is. Right click to clear it.
Bare Minimum
Bare Minimum will load the bare minimum needed for a new sketch. Select Run|Edit Sketch and the press
the rightmost button to load the Bare Minimum to start writing a sketch. The text will appear as shown
below. Modify and then click the button Save File As to save the sketch to a new filename.
10 / 34
Running a Sketch
After a sketch has been loaded, the first executable line of code will be highlighted. Now press the Step Into
button or the down arrow. Alternately, the F7 single step or F8 button may be pressed. The F9 button allows
the program to be autorun with a 5ms interval (adjustable) between steps. This 5ms time can be adjusted in
the Edit Window and for training, this can be set to 500ms to demonstrate in slow motion the operation of a
sketch.
The middle section of the screen displays the variables grid, and these are organised into Bytes, Chars,
Int(eger)s, Long, Strings and Defines. Any value in the grid can be changed by selecting it and typing in a
new number.
Hidden code
Special Simulator hidden code may be used to setup a particular hardware configuration, and this allows the
setup configuration to be saved inside the comments of the sketch.
This hidden code can be one fo four formats:
Simulate(Uno) - Simulate the particular Arduino board - please note that Simulate(Uno_LCD.txt) will also
work if the text file is found
breakpoint(line,tab, condition) - will setup a breakpoint at the line on the correct Tab, (leftmost=1) with
the condition. If the condition is left blank, it will not be set
SimulateLCD(x,y,width,height,pixel width,pixel space, backlight color, on color, off color) will setup a
LCD area on the Arduino picture. The colors are 24bit in a BGR format where 255=Red.The pixel width
should be no more than 5)
SimulateLED(x,y,width,height,color ) where color os the color of LED segments for a 7 segment display
SerialIn(data) will load the Serial Port input data with the data inside the parentheses
Stimulus(stim.sti) will load a Stimulus file. Stimulus actions are shown in the statusbar after the Next
line data and will happen at set times. View the _Sim Test\v98g\test.sti file for a sample
Sample Stimulus file
20,pinMode(1,OUTPUT); // at 20us make digPin1 an output
50,pinMode(5,OUTPUT); // at 50us make digPin5 an output
100,digitalWrite(5,HIGH); // at 100us turn on digPin5
Note that there is also a virtual library <Graphics.h> which allows for colour screen rendering. See the
Graphics.ino demo sketch under _Sim Test\v0.98 checks
Variables Area
The Variables area shows the status of all the variables used in program and their current value. The Value
may be changed by clicking in the relevant cell and changing the value. Please note that having a lot of
variables shown can slow the program execution. Either select Watch or Select Options> Show Variables
and turn this off to hide the variables to make program execution faster.
Double click in the first four columns to auto-resize the variable area.
Double Click in the Qualifier column or right click and select Watch to turn on Watch mode. This allows only
selected variables to be watched.
The Qualifier column typically shows if the value is a const, unsigned, static, volatile or pointer type (Note
that Pointers are not fully supported). The qualifier number in a heading row (shown by the gray shading)
shows how many variables of that type have been defined.
11 / 34
When returning from a subroutine, the stack will be returned the the original state, and any variables defined
in the subroutine or passed as arguments will be cleaned or removed.
Right Click in the Variables area to bring up the Pop-up Menu.
The second column is the watch column, and clicking in this column will show a w. The right click Pop-up
menu can then be selected to show only Watched variables. This is useful when only a few variables are
relevant amongst several hundred. The gray area in the W column may be clicked to show or hide all the
variables for that type. The last variable changed will always be shown for the last program step.
Arrays can be folded by clicking in the second or Watch column and a + sign will show that the Array has
been folded. When folded, only the first element of each array will be shown and for character arrays, the
string value of the whole array can be easily viewed. Alternately, the array may be folded at any element of
the array and in this case, the elements above will be shown, but the elements below will be hidden. Click
the + again to unfold the array
Clicking in the Qualifier column will enable or disable the watch, and the W in the second column indicates
if the Watch is on (W) or off (blank). The last variable changed will always be shown.
Find - open the Find window to find text inside the variables area
Clear All Variables - useful for header files which have a #ifdef FILE_H at the beginning. Clearing the
variables, then allows the header file to be stepped through. NOTE: doing this in the middle of stepping
through a sketch will cause errors since the Simulator will no longer be able to find or set variables.
Allow Undock/Dock - select this to undock or redock the Variables area from the main SImulator
window. If unchecked, the cvolumns may be resized.
12 / 34
Arduino Area
The Arduino picture area allows for the digital inputs and outputs to be displayed along with the Analog input
and output values. The digital pins are defined up to D53 for the Mega and D13 for the Uno.
The Analog Pins are defined as A0 to A5 for the Uno with A0 equal to 14. Other boards are setup according
to the Arduino configuration.
The Simulator also allows for custom boards to be setup.
Load Sketch - load a sketch into the program window - useful in minimize mode
Input/Output - show the input/output window - useful in minimize mode
13 / 34
Menu System
The Menu system has eight sub-menus. These menus allow the Simulator to be customised.
Note that right clicking in the toolbar will bring up a Language popup menu.
File Menu
Open Sketch in Notepad - this opens the sketch in Notepad for quick viewing and editing of the sketch
Open Sketch in Arduino - this opens the sketch in the Arduino IDE if Arduino is the default program to
open sketches. If this does not happen, right click a .ino sketch, select Open With and then Choose
Default Program and set to Arduino.exe
Log Errors - all errors will be logged to the ErrorLog + date.txt file Note that Errors here mean program
and simulator errors
Exit - close the program
Run Menu
14 / 34
View Menu
15 / 34
Hardware
16 / 34
LCD - Show the Virtronics custom LCD board with a 16x2 LCD fitted
LCD 8x2 - - Show the Virtronics custom LCD board with a 8x2 LCD fitted
Save Hardware Settings - save hardware settings to a .txt file which can be edited later
Load Hardware Settings - load hardware settings from a .txt file
Show All - Show all the pins, pin names and analog values for the Arduino board
Hide All - Hide all the pins, pin names and analog values for the Arduino board
The hardware settings are saved to a text file with the format shown below. Clicking anywhere on Arduino
picture will show the X,Y coorindates in the Status Bar and also save them to the clipboard.
Picture(Uno,350,506) // pix,width,height
resetSw(345,105) // Reset Switch x,y
onLed(273,454) // power led x,y
txLed(276,256)// transmit led x,y
rxLed(260,256)// receive led x,y
d13Led(309,256)// d13 led x,y
crystal(192,160)// crystal x,y
usb(250,32) // usb x,y
maxPin(13,5,19)// maxDigitalPin,maxAnalogPin,maxAllPins
externalInterrupts(2,3) // External Interrupts int0pin int1pin ...
LCD_Enabled(-29,-16,200,200,0,0,0,0,0)// x,y,w,h,pixel w, p-p,blit_color,oncolor,offcolor width=6*lcdx*p-p
height=10*lcdy*p-p - for graphic screen
digitalPin0(367,490,340,490,396,490) // pin x,y pin label x,y analogValue x,y
...
analogPin0(45,406,71,406,2,406) // analog label x,y pin x,y analogValue x,y
...
Tools
17 / 34
Automated Testing - the ability to automatically test series of sketched or commands. Very useful.
In all these Tools (except Automated Testing), the keyboard commands such as F7 to single step and F8 to
step one line at a time will work.
Logic Analyzer
The Logic Analyzer can show the pin states in a graphical format using the trace data.
The menu allows pins to be turned on and off, and scrolling the mouse wheel can expand or shrink the time
scale.
Options
All Pin On - turn on all 53 pins
All Pins Off - turn off all 53 pins
Pins 0-13 On - turn on the Arduino digital pins only
Pins 0-19 On - turn on the Arduino digital and Analog pins (analog pins 0-5 map to pins 14-19)
Debug - turn on a whole stack of debug data (may be removed at a later date)
18 / 34
Serial Monitor
The Serial Monitor is provided to be able to view real Serial Data.
The Serial Data will be transmitted from the Simulator out the designated Serial Port.
Unit Testing
19 / 34
Automated testing is an extensive page setup to automatically test sketches against set outputs. This
helps with testing the Simulator, and while it takes a lot longer to setup a test script, in the long term, this
will save much time.
At the bottom are 4 buttons labelled T1 to T4 and new. These are for routine tests which are all text files
found in the _Sim_Test folder:
T1 is for the Examples from 1.Basic up to and including ArduinoISP
T2 is for the rest of the Official Arduino examples using the standard libraries such as SPI, Wire and
Ethernet
T3 is for bug fixes and known previous issues
T4 is for a Simulator-oriented test script test each function as it is listed inside the Simulator source
code
New shows the latest test scripts added
Each line in a script file conforms to the following basic syntax:
test(function or variable, expected integer result expected float result, expected string result)
NA means not applicable or No test
Extra single letter functions are:
+ for single step
@for read data from Input/Output port using the integer result as the line number
(SoftSerial,Serial,SPI,EthernetClient,EthernetServer,Ethernet, Wire,LCD, KeyBoard,File & Udp)
! load a file
~digPin - read a digital pin state with the pin set by the integer result and check the colour is the same
as the expect float result read as an integer
The analog(x,val,NA,NA) can only be used once at the start of the script
Examples(Int,Float,Str,Output)
analog(0,123,NA,NA)
// ***** 0 BASIC *****
test(!01.Basics\AnalogReadSerial.ino,NA,NA,NA) // 1.1 AnalogReadSerial
test(+++sensorValue,123,NA,NA)
test(++@Serial,0,NA,123)
test(!01.Basics\Blink.ino,NA,NA,NA) // // 1.2 Blink.ino
test(+~digPin,13,0xffffff,NA)
test(++~digPin,13,255,NA)
test(+millis() ,1000,NA,NA)
test(+~digPin,13,0xffffff,NA)
test(+millis() ,2000,NA,NA)
Trace
Trace On - save all program steps to a text file with the filename based on the current date. the digital
pins state is also saved for the Logic Analyzer
Serial.Write - trace into all the output bits of each serial.write instruction and add time to the millis
20 / 34
The middle three options are specially designed for the Tool > Logic Analyzer and allow the digitalPin
changes to be view in real time similar to the way an oscilloscope would display the voltage levels. When
Trace On is selected or deselected, the lower 3 options are also selected or deselected.
Options
Help
21 / 34
Dialog Windows
The Simulator has several dialog windows which can display more information when activated. These are:
The Edit Window
The Input/Output Window
View Subroutines
Error Message
Edit Window
The Edit Sketch Window allows for sketches to be edited and updated or reloaded into the Program window
Close - closes this window and resumes simulating the program
Update Sketch - save this edited sketch back to the program window
Save File As - save this sketch to a new .ino file
SaveUpdate - save the sketch under the same name and update the sketch in the program window
Bare Minimum - load the bare minimum code skeleton - see here for more info
22 / 34
Sketch Font type - changes the font type of the main program window
Sketch Font size - changes the font size of the main program window
Skin - this will change and save the skin for the whole Simulator program. The default skin is Windows.
Click Invert to show text against a dark background
Library Directory - set for using custom libraries or click Reset to set the Library directory to the default
value
Language - change between English, French, Italian and Other for titles only - also Input and output the
language text
BreakPoint condition - set to break on a certain condition at the red line. The condition can be any
expression and can even be a formula - such as i+=10.
Serial InData - provides the ability to Change the Default Serial - Also available as a hidden code
command - Reset to set default value of 123456ABCDEF\n
AutoStep - the delay between single steps in the run mode
Syntax Colours - allows the user to adjust and save the syntax colours - Default will reset all colours
EEPROM Window
The EEPROM window allows for viewing and modifying of the EEPROM memory.
The EEPROM Window also has the added function of being able to view a full hex file contents, the ability to
view the contents in different formats (eg Decimal, Hex or Char) and being able to change and save the file.
there are many hexfile editors available on the internet and this feature is just a small part of the Simulator
23 / 34
Right click to bring up the popup menu which has several options:
Clear EEPROM - set all EEPROM memory to FF
Set All to 0 - all EEPROM memory to 00
Decimal - display Variables value in decimal
Hex - display Variables value in hexadecimal
Char - display Variables value in Character format and hexadecimal
Save to Hex File - save the EEPROM memory to a hex file
Load from Hex File - load the EEPROM memory from a hex file
Input/Output Window
The Simulation Window allows for data to be simulated for the six analog inputs for the Uno or 16 analog
inputs for the Mega. The window may be resized to be smaller, and the scrollbars and text boxes will
automatically resize to suit.
The ShiftIn and PulseIn allow the return values for these functions to be set.
The Analog Value may be changed by moving the respective scrollbar, or entering a new value in the white
Edit box.
Input and Output data is displayed in five ports. Each port has its own line for input data and a box for output
data. Each Port can be expanded or contracted to suit the display and resized.
The ports are assigned in the order they are setup.
24 / 34
25 / 34
View Subroutines
The View Subroutines window allows for the Subroutines to be viewed along with the number of parameters,
the line number and the tab. The line numbers may be viewed in the program window by selecting Line
Numbers
There is now a new Combo Box on the Shortcut toolbar which allows for all the subroutines to be viewed and
shown in the Program Window without changing the program counter.
Call Stack
The Call Stack displays the different levels of sketch loops in the left grid
The middle grid shows the Arduino objects, names and Enabled status.
The right grid shows classes found and objects derived from these classes.
26 / 34
Class Explorer
The Class Explorer allows for all the class variables to be viewed and inspected. These may only be
modified in the Variable Area at present.
Error Message
The Error message screen displays any code which the Simulator cannot process or which the Simulator
decides if an illegal operation such as:
the above operation, outside the setup() and loop() routines
setting a digital pin which is set to input
changing a const(ant) value
setting a variable to a value outside its limits
addressing an array element before the start or past the end of the array
The File|Log Errors option allows these errors to be logged to an ErrorLog +date.txt file.
The Log button will only be shown if the Error could be related to internal Simulator logic. If the Error
message starts with Sketch Error, the Simulator has guessed that it is more likely the error is in the
Sketch. If this is not the case, please email the sketch to [email protected]
Shortcut Toolbar
27 / 34
The Shortcut Toolbar provides single click actions for commonly used operations. Right Click on this toolbar
to show the Language popup menu which allows easy switching between English, French, and Italian( and
other languages when requested).
Button Functions:
Load - loads a sketch from the last used folder into the Simulator
Edit - Edit a sketch
Millis - the run time in milliseconds (NOTE: ms not seconds). This value can be changed at any time.
Each program step takes around 1us
Run - F9 AutoStep the program one instruction every xx ms The ms value can be edited. This time is
the delay between line execution and is not the actual speed of the program since each line may take
1-100ms to execute. If the AutoStep time period is set to 1ms, the variables, blue program traceline and
statusbar will not update to increase speed.
Abort - abort if the program is stuck in any loop
SubRoutines - contains a list of subroutines - select a subroutine from the list to jump and highlight in
blue that subroutine first line without affecting the program counter
The Milli seconds variable is displayed in a text box. This value can be adjusted by typing in a new value.
Each line of program execution takes 1us or 0.001. The commands Delay and delayMicroseconds will add
the accurate number of milliseconds or microseconds to the Millis Text box.
Shortcut keys
Several keyboard shortcuts have been added. These are
F2 for Reset
F3 for Find
F4 for Load a sketch
F5 to open the Simulation Window
F6 - Edit a sketch in the Edit Window
F7 to Step Into
F8 to Step Over
Shift F8 to Step out of a subroutine
F9 to Run or AutoStep
Ctrl-F for Find (same as F3)
F11 for Soft Reset
28 / 34
Example Sketches
Several sketches have been included for testing the Simulator. These are the Official Arduino examples in
the folders 01 Basics to 19 Wire.
In addition there are:
_Sim_Samples - Samples for the latest Youtube videos
_Sim_Shields - sketches to run on the custom Virtronics Shields for Arduino
_Sim_Test - test sketches and sketches sent in for error checking and fixing
_SIM_Extra - sketches with some new tryout features and sketches from the Videos
Libraries - this folder has some test Library sketches and various header files
In a typical install, the sample sketches will be found in this folder:
C:\Program Files\Virtronics
or for Windows 64 bit
C:\Program Files (x86)\Virtronics
Test Sketches
The test sketches are made up of issues with the Simulator and are used to do quick checks on patch
versions of the Simulator. The major releases of the Simulator are fully tested against most of the sample
sketches.
The test Sketches can be found in the _SIM_Test subfolder.
Language Processing
Keywords
The following words are defined as keywords and should not be redefined in a sketch:
defined(ARDUINO)
1
defined(__AVR__)
1
defined(__AVR_ATMEGA168__)
1 for Uno or 0 for Mega
defined(NUM_ANALOG_INPUTS)
6 for Uno or 16 for Mega
FALSE
0
TRUE
1
LOW
0
HIGH
1
ARDUINO
100
TOTAL_ANALOG_PINSX // unused - default return value of 1
TOTAL_PORTS
14
INPUT
0
OUTPUT
1
INPUT_PULLUP
2
TOTAL_PINSX
20
SD_CARD_TYPE_SD1 1
SD_CARD_TYPE_SD2 2
SD_CARD_TYPE_SD3 3
PI
3.1415926535897932384626433832795
HALF_PI
1.570796326794896619231321691639
TWO_PI
6.283185307179586476925286766559
DEG_TO_RAD
0.017453292519943295769236907684886
RAD_TO_DEG
57.295779513082320876798154814105
NUM_ANALOG_INPUTS 6 for Uno or 16 for Mega
29 / 34
TCC
0
NULL
0
DAC0
66
DAC1
67
ARDUINO
100
__AVR__
1
__AVR_ATmega328P__ 1 or 0
__AVR_ATMEGA168__ 0
NUM_ANALOG_INPUTS 6 or 16
__AVR_ARCH__
100
__AVR_ENHANCED__ 0
false
0
true
1
__GNUC__
4
__GNUC_MINOR__
3
__INT_MAX__
6
RASPBERRY_PI
0
WL_IDLE_STATUS
0
WL_CONNECTED
1
WL_NO_SHIELD
-1
MAX_SOCK_NUM
4
PINA-L (no PINI)
DDRA-L (no DDRI)
PORTA-L (no PORTI)
defined( ... )
Custom Libraries
The Simulator now has the ability to load custom libraries and single step through the code. Please note
that pointers are not supported and this is the typical reason for a library not to run.
To use a custom library, there are two methods. The first is to copy the header file and cpp file to the same
directory as the sketch, and then the Simulator will find these and load them in separate tabs.
The second method which is the preferred method is to use the library directory (.\Libraries) and then the
Simulator will automatically find the library header and source file and load them in separate tabs in the
Program Window. This method is better since the Simulator will find the files in the same place as the
Arduino IDE, and will save the effort of copying the files. The Library Directory can be setup by pressing F6
to load the Edit Sketch page and at the right hand side is an Edit Box which allows the Library directory to
be Set or Reset.
Millis
The Millis functions returns the number of milliseconds the program has been running for. In the Shortcut
toolbar, the Millis edit box shows the value of milliseconds as a floating point number. The micro function will
output this value * 1000.
Please note that the Simulator is not a real-time Simulator and runs around 1000 to 10000 times slower
than a real Arduino.
Troubleshooting
Menu has disappeared => resize the screen or right click on the Arduino picture and uncheck Minimize
The Language is wrong => Click Edit (second from left top button) and select language and change
back to the selected language
30 / 34
I have too many errors and just want to run my sketch => right click in the Sketch Window and uncheck
Errors Enabled
No Errors are appearing when they should => right click in the Sketch Window and check Errors
Enabled
An error has come up => click the Log button to log the error to Quality Central or Email to email the
error with the sketch
The Simulator doesn't work as expected => check the forum or email [email protected]
Registry Settings
Disclaimer: Do not use a registry editor to edit the registry directly unless you have no alternative. The
registry editors bypass the standard safeguards provided by administrative tools. These safeguards prevent
you from entering conflicting settings or settings that are likely to degrade performance or damage your
system. Editing the registry directly can have serious, unexpected consequences that can prevent the
system from starting and require that you reinstall Windows .
All the Simulator settings are saved in the registry under the key
HKEY_CURRENT_USER\SOFTWARE\SimForArduino x.xx where x.xx is the version number
The Registry settings can be viewed by running the RegEdit program or a similar utility.
Version Info
Version 0.99F - Mar-2014
1. Allow nested arrays test1[test2[0]]
2. Add syntax colours rectangles for different skins
3. Add Serial.readString
4. Improve timer1 interrupt - add all functions
5. Press ms after millis to increment by 1 second or timer1 interrupt when activated
6. Add hint to Millis text showing when next timer1 interrupt is due
7. Allow breakpoint on timer interrupt - ensure current instruction is executed before ISR
8. Add hidden commands to Stimulus file & Allow breakpoints when Stimulus file command run
9. Allow map instuction to run over 4 lines (an any instruction over any number of lines)
10. Fixup Serial Monitor echo only working for println but not print commands
11. Allow Arduino/ Variable sareas to undock and redock using x-axis
12. Add persistent vertical scrollbar to sktehc screen
13. Char array strings only shrink when Char is Selected - Hex no always show hex etc
14. Fixup Tools> Logic Analyzer
15. Add Chipkit Uno
Version 0.99E - Dec-2014
1. Add adjustable syntax colours
2. Move settings into separate folders in registry
3. Add timer interrupt
4. ms goes red and pressing triggers timer interrupt
5. Add 4 breakpoints
6. Allow multi char arrays
7. Fixup char arrays - convert to strings
8. Improve return function
9. Add in undock variables
10. Add in LED support using timer interrupts
11. Addin 4 breakpoint conditions
12. Improve breakpoint hidden command // breakpoint1(12,3,i=0)
13. Improve library directory finding
14. Allow arrays to be part shrunk in variables
31 / 34
32 / 34
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
33 / 34
Credits
This project has been a collaboration with many people.
Credit and thanks must go to these people for all their help: Adrian Wells, Marco Stuurman, Zeljko
Frankovic, Pete Lunt, Mark Grass Sr, Serge Desjardins, Peter Brouggy, Halam Rose, Larry Vatland,
Raimondas Butauskas, Jason Snow, J-Pierre Romanogli, Hamilton Elliott, Graeme Caie, Michael Moore,
Filipe Oliveira, Leon Rozengarten, Robert Lopez,Mauro Abbattista,Todd Radack,Alain Herben, George
Vrynios, Neko San, Mauro Abbattista, Alain Herben, Victor Aguilar, David Williams, Janis Gkatzaras,
Rodrigo Amaya, Ed Ross, David Cox, Shane Stenton, Freddie Snijman, Andres j. Ogayar, Anxionnaz
Yannick, Jeandaniel Planterose, Donald Dempsey, Enrique Condes, Peter Brown, Mladen Bruck, Jesse
Carneiro, Nigel Woodford, Ken Jensen, Koen Victor,Damir Kudeljan,Maxwell Yun, Douglas Hendricks,
Marco Baitelli, Howard Bassen, David Griffey, Patrick Beier, Fokko Dusseljee and few thousand more we
will add when there is some spare time.
34 / 34