Arduino Commands Cheat Sheet




Arduino Cheatsheet very handy! The Mechatronics Guy writes –

I really love cheat sheets. In a lot of cases they can take the place of an entire manual. So I was surprised, given its popularity that I couldn’t find a single-page reference for the arduino online. I tried to make a sheet that captured all the things I hit the reference for while programming. What data type does the millis() function return? How long till that overflows again? How large can a long get? What baud rates can the serial handle?

Mar 19, 2016 - 'Arduino Cheat Sheet' is a poster that gives an overview of the most important Arduino commands and syntax. It is based on ArduinoCheatSheet by The Mechatronics Guy and created with Brian Amberg's baposter LaTeX poster style. All the information is based on the Arduino Language Reference website. Download.pdf version. A range of boards are available, all programmable using the Arduino IDE and Arduino coding library. This cheat sheet should help you with some of the basic commands you'll need to start programming Arduino boards. FREE DOWNLOAD: This cheat sheet is available as a downloadable PDF from our distribution partner, TradePub.

  • Arduino Cheatsheet This is an overview of the most important / commonly used Arduino commands.
  • Arduino.CC Duemilanove/ Nano/ Pro/ ProMini Mega # of IO 14 + 6 analog (Nano has 14+8) 54 + 16 analog Serial Pins 0 - RX. Visio-Arduino cheat sheet v02c.vsd Author.
  • A nice cheat sheet was posted a couple of years ago too. Got a link to it somewhere.

Grab the PDF here.

Program Execution

CommandShort formDescription
continuecRun the program
advance setupadv setupRun the program and stop at the beginning of setup() *
nextnExecute the next line of code (step over)
stepsStep into the next line of code
finishfinRun the program until the current function returns (step out)
nextinExecute the next instruction (step over)
stepisiStep into next instruction
untiluLike next, but doesn't go back in loops
Ctrl+CBreak the program at the current instruction

* The advance command will also stop if the current function returns

Breakpoints

CommandShort formDescription
info breakpointsi bDisplay a list of all the breakpoints
break loopb loopSet a breakpoint at the beginning of loop()
break 42b 42Set a breakpoint in line 42
break *0x156b *0x156Set a breakpoint at program address 0x156
tbreak looptb loopSet a one-time (temporary) breakpoint in loop()
clear loopcl loopDelete any breakpoints on loop()
clear 42cl 42Delete any breakpoints on line 42
delete 1d 1Delete breakpoint number 1
disabledisDisable all breakpoints
disable 1dis 1Disable breakpoint number 1
enableenEnable all breakpoints
enable 1en 1Enable breakpoint number 1
enable once 1en once 1Enable breakpoint number 1 for a single hit

Call Stack

CommandShort formDescription
backtracebtDisplay a backtrace of the current call stack
backtrace -fullbt -fuDisplay backtrace including local variables
info argsi arDump the arguments of the current function
info localsi loDump local variables and their values
info registersi rDump MCU registers
faas info argsfa i arDump the arguments of all functions in the call stack
frame 2f 2Select frame number 2
upGo one stack frame up (e.g. calling function)
downdoGo one stack frame down
Arduino Commands Cheat SheetSyntax

Inspecting Code

CommandShort formDescription
list loopl loopShow the source code of loop()
disassembledisasDisassemble the current program location
disassemble/sdisas/sDisassemble including source code
disassemble/rdisas/rDisassemble including opcodes (in hex)
disassemble loopdisas loopDisassemble the loop() function

Inspecting Data

CommandShort formDescription
print $pcp $pcPrint the value of PC (Program Counter)
print $r0p $r0Print the value of the R0 register
print ip iPrint the value of the variable i
print PORTBp PORTBPrint the value of the I/O register PORTB
dprint loop,'Loopn'dp …Print 'Loop' every time loop() starts
dprint loop,'%dn',idp …Print the value of i every time loop() starts
x/16b $spDump 16 memory bytes starting at $sp (stack pointer)
x/10w 0x800200Dump 10 dwords starting at data space address 0x200
x/s 0x800151Dump a string from the data space address 0x151
display someVardisp someVarDisplay the value of someVar whenever the program stops
info displayi diList active auto-display (watch) expressions
delete display 1d d 1Delete auto-display expression number 1

Modifying Data

CommandShort formDescription
set i = 0s i=0Change the value of variable i to 0
set $pc = 0s $pc=0Jump to the beginning of the program
set $r12 = 0x55s $r12=0x55Set r12 to 0x55
set PORTB = 0xffs PORTB=0xffSet PORTB (I/O register) to 0xff
set {int}0x800200 = 50s …Set an integer at dataspace address 0x200 to 50

Text User Interface (TUI)

CommandShort formDescription
tui enabletu eEnabled the TUI mode (also Ctrl X+A)
tui disabletu dEnabled the TUI mode (also Ctrl X+A)
tui reg alltu r aDisplay registers window
layout asmla aSwitch to Assembly view
layout srcla srSwitch to Source Code view
layout splitla spSwitch to Split (Assembly + Source Code) view
updateupdShow the current line in the Source Code window
Ctrl+LRedraw the screen

Other commands

Commands
CommandShort formDescription
(empty line)Repeat the previous command
help continueh cShow help about the 'continue' command
help breakh bShow help about the 'break' command
help breakpointsh breakpointsDisplay a list of all breakpoint-related commands
quitqExit GDB (in Wokwi Web GDB, GDB will restart)

Using GDB with the Wokwi Simulator

You can use the Wokwi simulator to play around with GDB and debug your Arduino code.

To start a GDB session, open any project on Wokwi (e.g. this Simon game), click on the code editor, and press F1. In the prompt that opens, type 'GDB':

Then choose one of the options to launch GDB in a new browser tab. In general, the 'debug build' is recommended for optimal debugging experience, but some libraries (e.g. FastLED) may not function correctly without the compiler optimizations.

I suggest to start with the 'debug build', and switch to the 'release build' only if the program doesn't work correctly.

The Web GDB app takes about 30 seconds to start for the first time, and should load within a few seconds after the first time.

Arduino Code Cheat Sheet Pdf

When GDB is ready, it should print something like:

Arduino Commands And Syntax

At this point, you can write continue to start running the program, advance setup to run the program and stop at the beginning of the setup() function, or any other command from the GDB cheat sheet above.

Arduino Commands Explained

P.S. if you are curious, here's how I got GDB to run in the browser.