Please enable JavaScript to use CodeHS


Intro to Programming with Karel and micro:bit

Lessons

  1. Introduction to Programming

    1. 1.1 Introduction to Programming With Karel

    2. Description

      Students are introduced to CodeHS and how Karel the Dog can be given a set of instructions to perform a simple task.

    3. Objective

      Introduce students to Karel and explain the commands she can be given.

    4. 1.2 More Basic Karel

    5. Description

      Students will learn about Karel’s ‘World’ and the ways that Karel can interact with it.

    6. Objective

      To introduce students to Karel’s world and more of the commands that we can teach Karel

    7. 1.3 Karel Can't Turn Right

    8. Description

      Karel can learn new words or commands through the use of functions. This is called defining a functions. Defining functions has syntax rules.

    9. Objective

      Use Karel and commands to introduce students to functions.

    10. 1.4 What is a Computer?

    11. Description

      When was the first computer made? What did it look like, and what was it used for? In this lesson, students will learn about the creation and evolution of computing machines that now permeate our day-to-day life.

    12. Objective

      Students will be able to…
      * Discuss the question “What is a Computer?” with their peers
      * Identify important historical events in the development of modern computers
      * Describe the role computers play in their lives

  2. Intro to micro:bit

    1. 2.1 Welcome to micro:bit!

    2. Description

      In this first lesson, students will be introduced to their micro:bit device and the MakeCode editor, where they will build and test programs throughout the course. They will also be guided through the process to download programs from the editor to their device and will learn a few basic commands to get started writing micro:bit programs.

    3. Objective

      Students will be able to:

      • Articulate what physical computing is
      • Download and run programs on their micro:bit device in order to physically view programs as they create them throughout the course
      • Use the showNumber and showString commands in micro:bit programs
    4. 2.2 Setting Up your micro:bit

    5. Description

      In this lesson, students will take a deeper look at developing, testing, and running programs on the micro:bit simulator and on their devices. They will learn how the 5x5 grid system is laid out and will utilize more commands to light specific LEDs on the screen.

    6. Objective

      Students will be able to:

      • Develop, test, and run programs both on the micro:bit simulator and on physical devices
      • Use the MakeCode grid numbering system to light specific LEDs on the 5x5 LED screen
      • Use the led.plot, led.unplot, and basic.pause commands in micro:bit programs
    7. 2.3 Comments & Pseudocode

    8. Description

      In this lesson, students will learn about comments and pseudocode, why they are important, and how they help organize and plan programs. They will also learn the basic difference between analog and digital components and how to use the plotBrightness and clearScreen commands in their programs.

    9. Objective

      Students will be able to:

      • Use comments to write more readable programs
      • Develop pseudocode in order to properly plan and organize their programs
      • Use the plotBrightness and clearScreen commands in micro:bit programs
    10. 2.4 Variables

    11. Description

      In this lesson, students will build their first physical circuit using their micro:bit devices. They will learn to use variables to control components, along with the analogWritePin and digitalWritePin commands.

    12. Objective

      Students will be able to:

      • Articulate what a variable is and why they are used
      • Assign and utilize variable in their programs
      • Create a simple circuit using micro:bit pins
      • Control an external LED by using the analogWritePin and digitalWritePin commands in micro:bit programs
    13. 2.5 Intro to micro:bit Quiz

    14. Description

      In this lesson, students review content with a 15 question Unit Quiz.

    15. Objective

      Students will be able to:

      • Prove their knowledge of basic coding concepts through a multiple choice quiz
  3. Functions

    1. 3.1 Functions in Karel

    2. Description

      Functions are used to teach Karel a word or command. Using functions allow us to break down our program into smaller pieces and make it easier to understand.

    3. Objective

      Help students understand what functions are for and how using them improves programs.

    4. 3.2 More Practice with Functions

    5. Description

      This lesson provides students with extra practice in creating custom functions.

    6. Objective

      Students will be able to:

      • Create their own functions
      • Utilize functions to create higher order programs that go beyond the basic toolbox of Karel commands
      • Debug programs that use functions incorrectly
    7. 3.3 The Start Function

    8. Description

      All programs start by “calling” the start function.

    9. Objective

      Students gain a deeper understanding of functions. Students can explain the importance of writing readable code, and can analyze and compare the readability of different programs. Students can use the start function to make their programs more readable.

    10. 3.4 Top Down Design and Decomposition in Karel

    11. Description

      Top down design and Decomposition are the processes of breaking down a program into functions into smaller parts to avoid repeated code and make our program more readable.

    12. Objective

      Students will be able to…
      * Break a large problem down into smaller pieces
      * Write methods to solve each smaller problem
      * Solve a complicated problem using Top Down Design
      * Identify good and poor decomposition

  4. Super Karel and For Loops

    1. 4.1 Commenting Your Code

    2. Description

      Comments give notes to the reader to explain what your code is doing. Two types of comments that can utilized are preconditions and postconditions. Preconditions are assumptions we make about what is true before a function is called in our program. Postconditions are what should be true after a function is called in our program.

    3. Objective

      Students will be able to…
      * Explain the preconditions and postconditions of a function
      * Create clear and readable comments in their code that help the reader understand the code
      * Explain the purpose of comments

    4. 4.2 Super Karel

    5. Description

      Introducing Super Karel! Since commands like turnRight() and turnAround() are so commonly used, we shouldn’t have to define them in every single program. They should come prepackaged with the Karel library. This is where SuperKarel comes in. SuperKarel is just like Karel, except SuperKarel already knows how to turnRight and turnAround, so we don’t have to define those methods ourselves anymore.

    6. Objective

      Students will be able to…
      * Write programs that use SuperKarel instead of Karel
      * Utilize the new toolbox of commands that SuperKarel provides over Karel
      * Read documentation to understand how to use a library (SuperKarel is an example of this)

    7. 4.3 For Loops

    8. Description

      This lesson teaches students how to use for loops in their programs. The for loop allows you to repeat a specific part of code a fixed number of times.

      We write for loops like this:

      for(var i = 0; i < 4; i++)
      {
          // Code to be repeated 4 times
      }
      
    9. Objective

      Students will be able to…
      * Create for loops to repeat code a fixed number of times
      * Explain when a for loop would be a useful tool
      * Utilize for loops to write programs that would be difficult / impossible without loops

    10. 4.4 More Practice with For Loops

    11. Description

      This lesson gives students more practice creating and debugging for loops. The for loop allows you to repeat a specific part of code a fixed number of times.

    12. Objective

      Students will be able to…
      * Create for loops to repeat code a fixed number of times
      * Debug programs with incorrect for loop usage
      * Explain when a for loop should be used

  5. If Statements

    1. 5.1 If Statements

    2. Description
      • A condition is a function that returns a true/false answer.
      • JavaScript uses if statements as a way to make decisions and execute specific code. If statements are helpful in writing code that can be used in different situations.
    3. Objective

      Students will be able to…
      * Use conditions to gather information about Karel’s world (is the front clear, is Karel facing north, etc)
      * Create if statements to only execute code if a certain condition is true

    4. 5.2 If/Else Statements

    5. Description

      In this lesson we take a look at more conditional statements, more specifically if/else statements. If/else statements let us do one thing if a condition is true, and something else otherwise.

      We write if/else statements like this:

      if(frontIsClear()) {
          // code to execute if front is clear
      } else {
          // code to execute otherwise
      }
      
    6. Objective

      Students will be able to…
      * Explain the purpose of an If/Else statement
      * Create If/Else statements to solve new types of problems
      * Identify when an If/Else statement is appropriate to be used

    7. 5.3 More Practice

    8. Description

      This lesson is more practice with if statements and if / else statements.

      In this lesson we take a look at more conditional statements, more specifically if/else statements. If/else statements let us do one thing if a condition is true, and something else otherwise.

      We write if/else statements like this:

      if(frontIsClear()) {
          // code to execute if front is clear
      } else {
          // code to execute otherwise
      }
      
    9. Objective

      Students will be able to…
      * Explain the purpose of an If/Else statement
      * Create If/Else statements to solve new types of problems
      * Identify when an If/Else statement is appropriate to be used

  6. While Loops

    1. 6.1 While Loops in Karel

    2. Description

      In this lesson we introduce a new type of loop: while loops. While loops allow Karel to repeat code while a certain condition is true. While loops allow us to create general solutions to problems that will work on multiple Karel worlds, rather than just one.

    3. Objective

      Students will be able to…
      * Explain the purpose of a while loop
      * Create while loops to repeat code while a condition is true
      * Utilize while loops to solve new types of problems
      * Test their solutions on different Karel worlds

    4. 6.2 More Practice with While Loops

    5. Description

      In this lesson we’ll practice solving more problems with while loops.

      While loops allow Karel to repeat code while a certain condition is true. While loops allow us to create general solutions to problems that will work on multiple Karel worlds, rather than just one.

    6. Objective

      Students will be able to…
      * Explain the purpose of a while loop
      * Create while loops to repeat code while a condition is true
      * Utilize while loops to solve new types of problems
      * Test their solutions on different Karel worlds

  7. Program Control with micro:bit

    1. 7.1 For Loops

    2. Description

      In this lesson, students will connect a speaker to their physical circuit to play music using their micro:bit! They will learn to use for loops to control components, along with the playNote command.

    3. Objective

      Students will be able to:

      • Use for loops to control the flow of their programs
      • Control an external speaker by using the playNote command in micro:bit programs
      • Understand the correlation between frequency values and the pitch of a tone
    4. 7.2 While Loops

    5. Description

      In this lesson, students will learn how to use the built-in buttons to control their programs and will learn to use while loops to control components.

    6. Objective

      Students will be able to:

      • Use while loops to control the flow of their programs
      • Use buttons to control their programs
    7. 7.3 Operators

    8. Description

      In this lesson, students will learn about sensors and why they are so important in physical computing. They will use various internal sensors to detect attributes of the micro:bit’s environment and write programs that will complete certain tasks based on these values.

    9. Objective

      Students will be able to:

      • Use operators to control the flow of their programs
      • Use the reading of internal sensors to control commands in micro:bit programs
    10. 7.4 If/Else Statements

    11. Description

      In this lesson, students will connect a micro servo motor to their physical circuit and control its location using their device. They will learn to use conditionals to control components, along with the servoWritePin command.

    12. Objective

      Students will be able to:

      • Use conditionals to control the flow of their programs
      • Control the position of a servo motor by using the servoWritePin command in micro:bit programs
    13. 7.5 Functions

    14. Description

      In this lesson, students will use their first external sensor, an ultrasonic range finder, to measure distance and control components in the programs. They will develop and use functions with and without parameters to more clearly organize their code and make it more reusable.

    15. Objective

      Students will be able to:

      • Use functions with and without parameters to create more organized and reusable programs
      • Use an ultrasonic range finder to sense distance and control components in their micro:bit programs
    16. 7.6 Program Control with micro:bit Quiz

    17. Description

      In this lesson, students review content with a 14 question Unit Quiz.

    18. Objective

      Students will be able to:

      • Prove their knowledge of basic coding concepts through a multiple choice quiz
  8. Control Structures

    1. 8.1 Control Structures Example

    2. Description

      In this lesson we take a look at control structures. Some control structures allow us to ask questions: if, if / else statements. Other control structures allow us to repeat code like for loops and while loops. Basically, control structures allow us to control the way the commands execute.

    3. Objective

      Students will be able to:

      • Identify the different control structures we can use to modify the flow of control through a program
      • Combine control structures to solve complicated problems
      • Choose the proper control structure for a given problem
    4. 8.2 More Karel Examples and Testing

    5. Description

      Control structures (like loops and if statements) are useful in building programs that can be applied in various Karel worlds. This lesson is designed to test students’ knowledge of control structures in preparation for the upcoming Karel challenges.

    6. Objective

      Students will be able to…
      * Analyze a solution to a problem and explain why it works
      * Use control structures to create general solutions that work on all Karel worlds

    7. 8.3 How to Indent Your Code

    8. Description

      Indentation is especially important when using multiple loops, functions, and if statements to show the structure of the code. The indentation gives you a good visual way to see what commands are inside vs. outside of a loop or if statement.

    9. Objective

      Students will be able to…
      * Explain why it is important to indent code
      * Identify proper indentation
      * Modify a program to have proper indentation
      * Write programs with proper indentation

    10. 8.4 Ultra Karel

    11. Description
    12. Objective
  9. Karel Challenges

    1. 9.1 Karel Challenges

    2. Description

      It’s time to put it all together! Students have learned all of Karel’s abilities, and have practiced writing programs to solve Karel problems. In this lesson, students will synthesize all of the skills and concepts learned in the Karel unit to solve increasingly challenging Karel puzzles.

    3. Objective

      Students will be able to…
      * Define a problem in their own words and plan out a solution to the problem
      * Break a large problem down into smaller pieces and solve each of the pieces, then use these solutions as building blocks to solve the larger problem
      * Utilize the proper control structures to create general solutions that solve multiple Karel worlds
      * Write clear and readable code using control structures, functions, decomposition, and comments

  10. Advanced micro:bit

    1. 10.1 micro:bit Challenges

    2. Description

      In this lesson, students will learn why and how breadboards are used to build more complex circuits. They will experiment with different built-in Gestures and will use all of the concepts they’ve learned up to this point to complete their first larger projects- a digital watch and an Inchworm.

    3. Objective

      Students will be able to:

      • Use control structures to develop readable, concise, and effective programs
      • Use breadboards to build more complex circuits
    4. 10.2 Explore a New Sensor

    5. Description

      In this lesson, students will research, develop, and present a lesson to their peers on the use of a new sensor with their micro:bit devices.

    6. Objective

      Students will be able to:

      • Research how to use a new sensor with their micro:bit devices
      • Develop and present a lesson to their peers instructing them on how to use a new sensor in their programs
    7. 10.3 Follow a Step-by-Step Project

    8. Description

      Students will get a chance to follow instructions written by someone they’ve never met to replicate a project in this lesson. They will then evaluate and improve these directions to make them more effective for a target audience.

    9. Objective

      Students will be able to:

      • Follow step-by-step instructions to build complex circuits using breadboards
      • Evaluate the clarity and effectiveness of given instructions
      • Improve directions to more effectively serve a specific audience
    10. 10.4 Final Project

    11. Description

      In this final lesson, students will put together all of the concepts learned throughout the course to create a project of their choice. They will work individually, or with partners or groups to creatively develop a program of their choosing.

    12. Objective

      Students will be able to:

      • Synthesize concepts and skills learned in the course to create their own final project
      • Scope their project (eliminate features that aren’t necessary) so that it fits in the timeframe allotted
      • Present their project to their classmates and talk about how the project was developed
  11. Final Project

    1. 11.1 Final Project

    2. Description

      In this lesson, students use all of their programming skills to create their very own Karel project from scratch!

    3. Objective

      Students will be able to:

      • Synthesize concepts and skills learned in the course to create their own final project.
      • Scope their project (eliminate features that aren’t necessary) so that it fits in the timeframe allotted.
      • Complete an error-free Karel project of their own design.
      • Present their project to their classmates and talk about how the project was developed.
  12. Extra Karel Practice

    1. 12.1 Extra Karel Practice

    2. Description
    3. Objective
  13. Extra Karel Challenges

    1. 13.1 Extra Karel Puzzles

    2. Description
    3. Objective
  14. Using Variables in JavaScript

    1. 14.1 Hello World

    2. Description

      In this lesson, students will learn how to print messages out onto the console using the Javascript command println.

    3. Objective

      Students will be able to:

      • Write a JavaScript program by typing commands with proper syntax in the start function
      • Write a program that prints out a message to the user
    4. 14.2 Variables

    5. Description

      In this lesson, students learn how to assign values to variables, manipulate those variable values, and use them in program statements. This is the introductory lesson into how data can be stored in variables.

    6. Objective

      Students will be able to…

      • Explain what variables are and what they are used for
      • Create their own variables
      • Print out the values stored in variables