1 - Intro Programming

Unit 1 - Introduction to Programming

How do you create a program that responds to user/environmental input?

Am I Ready to Try This?

Before beginning this unit, you should have completed the tasks in "0 - Initial Setup."

What Am I Learning and Why Am I Learning This Now?

One difference between a "robot" and a "machine" is that robots sense their environment in some way and then respond as they were programmed. When you complete this initial unit, you'll be able to write simple programs to respond to inputs/events, and you will have practiced communicating your engineering method. You will have "met" competency 2, and you will have a formative assessment of your engineering journal for competency 1. (In the next unit, you will learn to use gears for creating different kinds of motion.)

There are many different programming languages. At the beginning of this unit, you will do a formative assessment of your programming background. You will work with the teacher to develop some initial learning activities as needed before you begin working with your robot. If you have never learned any programming, Code Academy's Hour of Code is a great starting place! You might also start with something like MSWLogo or HopScotch before you begin programming your LEGO robot. If you have good internet access, TurtleAcademy.com might help. Most students will eventually use a LEGO programming environment, such as EV3. If you have a lot of programming experience, you might download a version of C into a LEGO RCX for this course.

Different languages are designed to work with different kinds of inputs/outputs, or events/responses. For example, JavaScript makes it easy to respond to a user click on a web page by changing the content on the page. The LEGO programming environment/language makes it easy to respond to a sensor by turning on a motor. In this unit, you should learn how to program with each of your robot's possible sensors and actions. (In the next programming unit, you will learn to store and manipulate values/inputs.)

All languages have control structures that direct the "flow" of the program. Different languages/environments use different syntax. In this unit, you should learn how to use the available basic control structures for conditionals and looping. (Examples: Loop, Fork, Task Split, Case, If/Then, Do/While, On Event, Goto/Gosub, Function/Subroutine Calls) Note that you are not expected to use variables or passed values in your control structures until the next programming unit.

Robotics Learning Project: BabyBot

Create a "baby bot" -- a basic robot that responds to at least two different kinds of input. The robot should respond to the inputs in any order, and should continue to respond to the inputs. Responses for each sensor must be unique. For example, program your robot to turn on its light whenever it gets dark, and to "giggle" (make a sound) whenever it's touched... Note that a "baby" bot does not have to be a moving vehicle.

Minimum Project Expectations

Robot:

Robot meets the requirements of the task. (Use the description above to define your task, including criteria for success and parameters. Be sure to check in with the teacher to be sure you have this first journal entry correct.)

Engineering Journal:

Entries for every required section

At least four different initial sketches / programming block ideas with evaluation (pros/cons)

Parts Analysis has about three system parts

Test-Result-Change section has at least four screenshots of programs (or sections of programs) that you tested

Final diagrams of your bot and program

How to Navigate this Unit:

  1. KNOW YOUR GOAL: READ the rubrics for competency 1 (Engineering Process) and competency 2 (intro programming). Ask for clarification of expectations as needed. (Remember that all the rubrics are on the "Competency Rubrics" page of this site. The link is in the left-side navigation menu.)

  2. READINESS CHECK: Schedule a formal conversation with your teacher about your programming background. Based on this formative assessment, your teacher may work with you to adjust your experience in this unit. If you have never programmed before, your teacher may provide some direct instruction and supplemental programming tasks. If you are very experienced, your teacher may help you design an alternative project.

  3. LEARN: You will need to do RESEARCH in order to define your "BabyBot" objectives and brainstorm options. Make a "BabyBot Notebook" in a Google Doc or in your paper notebook. Use it to record information about control structures, inputs, and responses. (You do NOT need to do these in this specific order. )

    • Explore the different outputs / responses that you have available in your programming environment. For example, how do you turn on the motors? how do you have the robot make sound? turn on lights? display information on the screen? Are there other outputs available?

    • For each of the following, describe in your own words and explain (screenshots?) how to code the structure in your robotics programming environment:

      • Sequence: How do you "start" a program? How do you define the order of the commands? How can you tell your robot to pay attention to two or more things at the same time? How do you define an "end"?

      • Comparisons/Selectors: How do you tell the program to check some condition, and then do something based on what it finds?

      • Loops: How do you tell the program to keep doing something? How do you tell the program to repeat some behavior a specific number of times? How do you tell it to do something only while some condition is met?

      • Subroutines/Functions: How do you create and call a "mini-program" that you can use over and over? (Note - you do not have to be able to pass variables in this unit.)

      • Be sure to explore options. Seek to understand what the different structures do. Don't "settle" for meeting the bare minimum requirements of the project.

    • Explore the different inputs / senses you that you have available in your programming environment. For example, how do you use the touch sensor? what other sensors do you have, and how are they programmed?

  4. LEARN: Begin the "BabyBot" Learning Project. Be sure to document your engineering process in your journal.

      • Define the task in terms of criteria for success and parameters/restrictions.

      • Brainstorm some initial ideas and evaluate them.

      • Analyze your "parts" - how should you break down the task? What kinds of commands will you need? Add your objectives to your task definition, and chart your algorithm.

      • PROGRESS CHECK: schedule a quick formal progress check with your teacher before you begin testing programs

      • Then start testing -- test and correct the individual parts before you try to test the whole system.

      • PROGRESS CHECK: schedule a quick formal progress check with your teacher DURING your testing cycle. This must happen before you "finish" your BabyBot.

  5. READINESS CHECK: When you have completed the Baby Bot and feel that you meet the requirements of Competency 2, "turn in" your project engineering journal and schedule an assessment conversation with your teacher. During the assessment conversation, show your teacher your Baby Bot and answer your teacher's questions about your project. Based on this formative assessment, your teacher may ask you complete some additional tasks or research to help you reach mastery of competency 2 (intro programming) or improve your skills in competency 1 (engineering process).

  6. SUMMATIVE ASSESSMENT: When your teacher agrees you are ready, schedule your intro programming exam. This individual assessment has two parts. In one part you will need to interpret/explain a written program. In the other part, you will be able to interact with a BabyBot; you will need to create the program that will cause the same behaviors. NOTE - once you have scheduled your exam, you can begin Unit 2 on gears. There may be a considerable time delay between the time you are ready to take the exam and the time the exam can be scheduled.

As always, if you want to demonstrate your mastery of competency 2 in an alternate way, just propose it to the teacher for consideration IN ADVANCE.

Resources:

Be sure to check the resources folder for notes on the structure of your engineering journal.

Do a google search on your programming language -- you will find lots of reference and tutorial sites. Be sure to make use of YouTube! (For Example, LEGO's EV3 site: http://www.lego.com/en-us/mindstorms/learn-to-program.)

Wiring LEDs / other outputs to codable pins on the raspberry pi, and the PYTHON commands for them: https://projects.raspberrypi.org/en/projects/physical-computing/1

Basic Control Structures (Google "programming control structures") (Caution, use the language you are coding in!)

Control Structures

WikiUniversity

JAVA control structures

EV3 - good intro to control structures

If you've never programmed... Use Code Academy: https://studio.code.org/

Minecraft Hour of Code: https://code.org/mc