
1
SKILL
LEVEL Learn to Code - Ch01 Rev01.3 ~ Plum Geek
Arduino Super Basics
In the world of Arduino, the window where you write your code is called a “sketch”. You
could also call this “source code”. Have a look at how the window is set up.
How the code window is set up...
/*
Everything in this area is a “comment”. Comments tell you
what the program does and other information. The computer
ignores comments. They are just to help humans understand
the co de.
*/
void setup(){
hardwareBegin(); //setup processor to work with the robot
}
void loop(){
eyesPurple(100); //both eyes purple
delay(3000); //wait 3 seconds
rightOff(); //turn off right eye (so he “winks”)
delay(250); //wait 1/4 second
}
Use comments to tell yourself or other
human readers what the code is doing.
In-line comments can be created by using
a pair of forward slashes like this: //
(1) Press the Check Mark button to “verify” your code.
This compiles your code and tells you if you’ve written
anything the computer can’t understand.
(2) Press the Arrow button to compile then upload your
code to the robot’s brain.
(3) These are tabs. The first one has the name of your
sketch. The others are supporting tabs which have
background functions inside. More on these in the
advanced lessons.
(4) This is your code! It’s the stuff you edit to make the
robot do cool stuff. A code example is shown below.
(5) This is the messages area. This area will tell you
if you’ve made any mistakes in your code as well as
other useful information.
(6) This opens the Serial Monitor, which is a window
where the robot can send you messages which are
useful when “debugging” your code.
setup() runs one time when the processor
first starts. It is useful to configure the
initial setup of the processor.
This is where the fun happens. Everything
inside the loop() function is run over and
over. You’ll put most of your code inside
this function.
WinkHardware.h WinkHardware
/*
Everything in this area is a “comment”. Comments tell you
what the program does and other information. The computer
ignores comments. They are just to help humans understand
the code.
*/
void setup(){
HardwareBegin(); //Setup processor to work with the robot
}
void loop(){
EyesPurple(); //both eyes purple
delay(3000); //wait 3 seconds
RightOff(); //turn off right eye (so he “winks”)
delay(250); //wait 1/4 second
}
1
26
3
4
5
Lesson 1