Rather Read the Key Concept? Click here.


In this lesson, you'll probably see a number of new things, and some of them may look really confusing.

As you progress through the hour, always remember that code is written by people and it's written to do things for people.

The first lesson is about 'dissecting' a piece of code and seeing its parts. The most important part of the code for you to understand at this point are the comments. Comments in our code are the green words. They start with two forward slashes // or a */. When you see these comments, you've found a note from another programmer to you.

Reading comments should reveal the intent of the code. Keep in mind that the computer can't read comments, only you can. So when you change your code, you don't have to change your comments. All of the code that the computer can read is the rest of what you see in your code editor- black, orange, blue, and red characters.

So, even if you don't understand any of the computer code in the code editor, you can always read the comments to help you identify what each line of code does and how you might modify it to do something different.

Read all of the green comments in this program and try to determine the title of the program, what it should do, and how each line of code impacts the resulting program.

Now, let's get started!

/* * Turn on the headlight */ void setup() { //the setup section of code starts here and all the code inside it runs one time pinMode(4,OUTPUT); //set your headlight LED as an OUTPUT } //the setup section of code ends here. void loop() { //the loop section of code starts here and all code inside here is repeated digitalWrite(4,HIGH); //Send power to pin 4 } //the loop ends here. When the code runs this line, it jumps to the top of the loop and repeats // (c) 2017 Let's Start Coding. License: www.letsstartcoding.com/bsdlicense

Walkthrough Videos

Watch the videos for line-by-line explanation of how the example program works. Then you'll be ready to make some changes of your own!


How many can you complete? Change the code according to the challenges below. Upload your code to see the effect when you're finished. Complete a challenge? Check it off the list!

Spread the word! Tell your friends, classmates, and family about your Hour of Code!