Lesson 1 Activities: Controlling LED Lights 

In these activities we will work with the 3 Lights on the Scribbler Robot. The lights, called L.E.Ds, can be turned on and off by using a special block in the BlocklyProp Editor.

Note: If you need to learn more about how to use the BlocklyProp Editor, review the Getting Started section to get more comfortable with basic navigation and block placement.

scribbler 3 leds

What is an LED? A light-emitting diode (LED) is a light source that is also a semiconductor. It emits light when voltage is applied to its leads (the wires that connect it to its power source - the battery).

We will be modifying the 3 bicolor indicator LED lights on the Scribbler. In this activity you will use code to turn on and off these LED lights.  They are called bicolor because these lights can be changed to red, amber, green, or off.  They are called indicator because they are indicating or letting us know about some condition in the robot.  We will learn more about that as we learn coding. Let’s get to it!

 

Here's what we will do:

 

Pre-Activity Check List:

Each lesson will have a check list to make sure you have everything you need before you dive into the activities. We call this the Pre-Activity Check list. Before moving into the activity steps, make sure you have all items on the check list completed! These are also included in your Worksheet document. Please check them off there.

  • Completed the Getting Started Lesson.
  • Reviewed the lesson materials.
  • Watched the concept and activity videos.
  • Scribbler S3 Robot is fully charged (blue light is on).
  • Scribbler is connected to a computer via USB cable and wheels are up in ‘garage mode’.
  • Clear area to work with the Robot still connected to your computer.
  • Started BlockyPropClient software on the computer, and pressed connect.
  • Have https://blockly.parallax.com website open in Internet Browser and have logged in.
  • Reviewed the LED Block Section of the Reference Guide Documentation

LEDs Activity 1 - Turn on one Light

Activity 1 Steps:

  1. Start a new project: Go to BlocklyProp in the Internet Browser. Click the menu in the upper right corner of the screen and select New Project. ac1 menu 01
    Type the Project name: LEDs Activity 1
    Description: Control the LEDs on the Robot
    Leave the sharing as Private, click on Finish.
  2. project info
    set private
  3. To modify the indicator lights, select  Actions from the menu and Choose LEDs. 
    Let’s choose the block that says Change These LEDs and drag it into our worksheet.

simple leds

  1. We only want one LED to be on, so uncheck the right and left boxes, and only leave the center checked. Then select green for the color of the center LED.ac1 block
  2. Save the Project.  Now here is the exciting part, we get to copy the program from the BlocklyProp Editor to the Scribbler Robot. 
  3. Make sure that the Scribbler is plugged into the USB cable and attached to the computer. Put the Scribbler in Garage Mode - with wheels up so they don't touch the table.

TIP:  It’s a good idea to prop the Scribbler up so the wheels don’t touch the table. This will prevent the Scribbler from running away from you and falling off a table or desk! 

  1. Turn on the Scribbler Robot and verify that the Blue Light is on. Then load the program onto the robot:
  • Verify the project by clicking on the green circle with the checkmark on it.verify code
  • Upload the program to the scribbler robot. by selecting the green circle with the down arrow on it.load and run
  • When the program starts copying from the Blockly Editor, through your computer, and onto the eeprom chip on the robot (or uploading as it is called in the programming world), you will see this message box:
loading start

If everything goes as planned, you will see these messages at the bottom, with OKs.

loading finished

NOTE: If you get a different message, please visit the Troubleshooting section.  Don’t worry, it is probably something very easy to fix!

  1. Now it is time to view the results of your first program!  Look at the Scribbler, the Center Light should be lit and the Left and Right lights should be off; just like in the block we set. Congratulations, you’re a Robotics Programmer!
  2. Now let's go back and add some notes to our program.leds activity 1
    1. Click Control
    2. Choose Add Comment and Drag onto Worksheet
    3. Connect it to the top of the other block
    4. Type into grey area ‘LED Activity 1’
    5. Add another Comment below first one  and type “Programmer: “ and your name. 
  3. If we want to modify or come back to this program at a later time, we need to save it. To save the project, click the “Save” button. (Note: you will know it saved if the button turns green and has a checkmark in it for just a moment.)

save button

11. Next, save a copy of the program to the area on the computer were you are supposed to save your files (as directed by your instructor).

      1. download blocks file highlight

        Click the menu in the upper right corner of the screen.

      2. Then select Download Blocks.

      3. Name the project as LEDsActivity1 and select comfirm to download it to your downloads folder.

      4. Then open up your downloads folder and find the file named LEDsActivity1.svg.

      5. Right click on the file and select cut, then navigate to the file area on the computer (or network) where you are supposed to save your files (as directed by your instructor), and select paste.

12. Fill out the worksheet questions for this activity.

TIP: Always be sure to name your projects something that you will recognize later, like “LEDActivity01.scb” or “LightsOn.scb.” Follow your instructor's guidelines for naming files and where to save your files.

 

LEDs Activity 2 - Turn on all Lights

Activity 2 Steps:

leds activity 2
  1. Start a new Project 
    1. Project Name: LEDs Activity 2
    2. Board/Device type: Scribbler Robot
    3. Description: Set each LED to a Different color
    4. Sharing: Private
  2. Add comments to describe the project.
    1. Select Control, choose Add Comment and Drag onto Worksheet
    2. Type into grey area ‘LED Activity 2’
    3. Add another Comment below first one  and type “Programmer: “ and your name.
    4. Finaly add another Comment below the second one and type in "Set each LED to a Different color"
  3. Add LED Block commands - duplicate them.
    1. Select Actions and LEDs. Let's choose the block that says Change These LEDs and drag it into our worksheet.
    2. Unselect the left and right check boxes and change the center color box to green.
    3. Right click on the LED Block and select Duplicate.
    4. In the copied block, unselect the center check box and select the left check box.
    5. Change the color of the left color box to red and chnage the center color box to black.
    6. Right click on the LED Block and select duplicate.
    7. In the copied block, unselect the left check box and select the right check box.
    8. Change the color of the right color box to amber and change the left color box to black.
  4. Add a pause between the LED blocks.wait
    1. Click Control, and choose the Wait block. Drag it onto the Worksheet  and click it under the first LED block.
    2. In the Wait block, change milliseconds to seconds, then change 500 to 1, so it will wait for 1 second.
    3. Right click on the wait Block and select duplicate then place the copy under the second LED Block.
    4. Right click on the wait Block and select duplicate then place the copy under the third LED Block.
  5. Save the project.
  6. Upload and run the program on the Robot.
    1. Make sure that the Scribbler is plugged into the USB cable and attached to the computer (in Garage mode).
    2. Turn on the Scribbler Robot and verify that the Blue Light is on.
    3. Verify the project by clicking on the green circle with the checkmark on it. Verify code.
    4. Upload the program to the scribbler robot. by selecting the green circle with the down arrow on it. load and run. 
  7. Watch the program run on the robot. Did it work as you expected? You can see it run again by pressing the Blue reset button on the robot. 
  8. Make adjustments to the code blocks as necessary and repeat the save and upload steps until it works.
  9. Download the blocks file and copy it into the folder where you keep your files.
  10. Fill out the worksheet questions for this activity.

LEDs Activity 3 - Flashing Christmas Lights

Activity 3 Steps:

leds activity 3
  1. Open My Projects and select LEDs Activity 2 (if not already open). 
  2. From the Menu choose Save the Project as 
    1. Project Name: LEDs Activity 3
    2. Board/Device type: Scribbler Robot
    3. Description: Set each LED to a Different color
    4. Sharing: Private
  3. Change first Comment text to "LEDs Activity 3".
  4. Change the third Comment text to "Flash LEDs on and off"
  5. Add a loop to turn the lights on and off.
    1. Click Control and choose Loop Forever and drag onto Worksheet. Place it under the Comment blocks.
    2. Then drag the whole group of LED and Wait blocks into the Loop Block (see example code above)
  6. Change all the Wait blocks to 1 tenth of a second.
  7. Change all the LED blocks to set all the check marks on. (This will turn off the LEDs that are not being set to a color).
  8. Save the project.
  9. Upload and test your project.
    1. Make sure that the Scribbler is plugged into the USB cable and attached to the computer (in Garage mode).
    2. Turn on the Scribbler Robot and verify that the Blue Light is on.
    3. Verify the project by clicking on the green circle with the checkmark on it. Verify code.
    4. Upload the program to the scribbler robot by selecting the green circle with the down arrow on it. Load and run. 
  10. Watch the program run on the robot. Did it work as you expected? You can see it run again by pressing the reset button on the robot.
  11. Make adjustments to the code blocks as necessary and repeat the save and upload steps until it works.
  12. Download the blocks file and copy it into the folder where you keep your files.
  13. Fill out the worksheet questions for this activity.

LEDs Your Turn Challenges:

A: Make Scribbler act like a Police or Ambulance vehicle:

  1. Open My Projects and select LEDs Activity 3 (if not already open).
  2. Save the Project as LEDs Your Turn.

  3. Can you change the code to make the flashing lights look more like a police or ambulance vehicle with red lights flashing?

  4. Try it and make adjustments until you have it working.

  5. Don’t forget to save your code.

  6. Download the blocks file and copy it into the folder where you keep your files. 

  7. Take a screen capture for your worksheet.

Copyright 2017 Interactive Media Publishing, All rights reserved