Lesson 1

Getting Started

Now that you have set up your handheld with the Arduino software it is time to start making some code.

If you open a new Arduino project this is what it will look like.

Comments

Underlined here are comments

When we type code, what we are doing is typing instructions for our computer to build something. We say "hey, put Mario over here," or "this is how the car should move."

But sometimes we want to type messages to ourselves and other humans that we don't want the computer to read. These comments allow us to make notes about what code is suppose to do.

When you add two slashes everything after it will be a comment that the computer will ignore.

here is some code // and this is a comment

void setup() and void loop()

The setup() and loop() are the two main areas we will be typing code. If you read the comments you can get a hint at what they do.

Code in setup() runs once at the start of a program.

Code in loop() runs over and over in a... loop.

Add some Libraries

The first thing we need to do is add some libraries. When we code we don't want to have code the same old stuff over and over (like how to move a mouse or how to detect when a button is pushed) so what we do is we tell our program to include a Library.

We are going to add the Arduboy libraries which will tell our hardware how to do many things like how to turn on, put imagines on the screen, how to handle button, etc.

Type this code on top of the void setup()

#include <Arduboy2.h>

Arduboy2 arduboy;

Let's Boot Our Hardware Up!

Let's use that library we just added.

Type this code in between the { } brackets of the void setup()

arduboy.begin();

The first part of arduboy.begin(); is arduboy. It points to the library we just added.

Begin() is a function inside that library that tells the hardware how to turn on.

Push the new code over to the hardware and watch it boot!

Challenges:

Every lesson from here on out has a "Challenges" section. You should try to do these extra challenges as they will be how you actually learn to code. Anyone can copy and paste code someone else writes, but the challenges will teach you think about how to write your own code. Some challenges are SUPER hard and might be impossible for you to complete, but you should still think about how you might do them.

The Complete Code

#include <Arduboy2.h>

Arduboy2 arduboy;


void setup() {

// put your setup code here, to run once:

arduboy.begin();


}


void loop() {

// put your main code here, to run repeatedly:


}