1 / 54

PicoBoard and Scratch

Introduction to Programming and Physical Computing. PicoBoard and Scratch. Workshop Overview. Introductions The Learning Cycle (STEM  STEAM) What is physical computing Introduction to Scratch and animating a character Connecting to the outside world -- Plugging in the picoboard Slider

Download Presentation

PicoBoard and Scratch

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction to Programming and Physical Computing PicoBoard and Scratch

  2. Workshop Overview Introductions The Learning Cycle (STEM  STEAM) What is physical computing Introduction to Scratch and animating a character Connecting to the outside world -- Plugging in the picoboard Slider Additional resources

  3. The Learning Cycle Time to play, reflect, question and redesign

  4. General Rules… • Raise your hand if you have a question. • Be respectful. • When I raise my hand… • Share your findings with the people near you. • Poke around, experiment, and have fun… • Imagine, create, and play!!!

  5. About Us • SparkFun Electronics is all about creation, innovation and sharing information. We want to get you excited about cutting edge electronics technology with our hands on educational kits.

  6. What is Physical Computing Physical computing, in the broadest sense, means building interactive physical systems by the use of software and hardware that can sense and respond to the analog world -Wikipedia

  7. Resources • This PPT  http://bit.ly/SparkFunPicoScratch001 • http://scratched.media.mit.edu/sites/default/files/Getting_Started_With_PicoBoards.pdf • http://www.picocricket.com/picoboard.html

  8. What is Scratch?

  9. Scratch

  10. With the PicoBoard, your Scratch™ projects can sense – and respond to – things going on in the world outside your computer.

  11. Creating your first Animation

  12. Rotation Settings– Control how the sprite rotates: - rotate freely - face left \ right - locked (no rotation) Palette – Each of the 8 buttons will show you different functions Parts of the Screen Sprite Toolbar– Duplicate, Delete, Grow, Shrink Click & Drag Scripting Area Here’s where you build your program – stacking blocks togeteher to create unique functions.

  13. Scratch Exercise 1Choosing a Sprite and making it move in 4 directions

  14. Choosing your Sprite(Import from library) • A Sprite is any character or object in your game.  Sprites can move and be active or be props that stay still.  We will choose a Sprite character that will move about your screen. • Click on the Costumes Tab • Click ImportSelect a Folder (Animals, People, Things) • Pick a Sprite! (Double-Click)

  15. Choosing your Sprite(Camera!) • If your computer has a built-in camera, you can also take a picture of something you’ve drawn or created.You can use this to create stop-motion animations (think clay-mation\ Gumby…) Or… you can use the Paint option window to draw your own sprite

  16. Picking a Background (Stage) • Click on the Stage (lower right) • Click the Backgrounds Tab • Use the Paint / Import / Camera feature to pick your background.

  17. Making Your Sprite Move • Sprites can not do anything by themselves.  A Sprite's action comes from the scripts in the script window.  • Scripts are the instructions for exactly what the sprite will do.  You drag these instructions from the Tile pane into the "Scripts" pane.  • Tiles fit together like a puzzle to create the instructions.

  18. Event driven instructions • Click the Control button on the scripting palate. • There are 3 different events that you can use to trigger an instruction (code). • Click and drag one of these over to the scripting area.

  19. Making Your Sprite Move… • Click on the "Motion" button. • Drag "point in direction [90]" over to the Scripts window and connect it to the previous command. • Drag the “move [10] steps" tile and connect it. • Test it 

  20. Adding animation… • Scratch moves around – but doesn’t look like she’s actually walking. Click on Add the next costume block to our script. Test it 

  21. Play time… • Build an animation to introduce yourself to the class. Choose what key you will use to start. • Play with the various features / programming blocks in scratch. • Here are some examples: • http://scratch.mit.edu/projects/2665999/ • http://scratch.mit.edu/projects/2001868/ • http://scratch.mit.edu/projects/912524/

  22. Back to building simple motion • Save your introduction script. • All files save as *.sb • Start a new file that looks like this 

  23. Adding other controls make your sprite move backwards with another key press. • Right-click on the code block to copy (duplicate) what you’ve already done. • Click the box where it says space and change this to a different key.

  24. Voilla! • You’ve just created “game controls” for your character. • What else can you do?

  25. Plug it in the PicoBoard…

  26. Sensors

  27. Sensor Values • By default, all sensor values vary from 0 to 100. • Use this with Control Blocks to create conditional statements and integrate decision-making.

  28. Light Value • One of the examples in Scratch uses the light sensor in an interesting animation of the Sun. • Your sprite can react to light or shade using the data coming from this sensor.

  29. Slider Value • This sensor is useful because instead of being a binary sensor, like the button sensor (which turns on or off), this sensor changes continuously on a scale from 0 to 100.

  30. Sound Value • For example, a sprite can jump up in surprise if you yell into the sensor, but perhaps not do anything if you simply whisper into the sensor. • Your sprite can be programmed to react when this sensor detects sound.

  31. Button State (Boolean) • Make your sprite jump or change colors. • When you stop pushing the button, the sprite will go back to its original state. • Your sprite can be programmed to react when you push this button.

  32. Example: Slider Control • Start with the slide potentiometer. • Input Values: 0 – 100 • Take these blocks and make this:

  33. Scratch • Scratch rotates from 0 degrees to 100 degrees • How can we use this to get her to rotate a full circle?

  34. Math Lesson:Rotating a full circle = 360 deg

  35. Rotating a full circle = 360 deg • Using the • palette, pull out the divide and the multiply blocks. • Combine these to get the desired formula.

  36. Like this?

  37. Drop this into where you had the angle before

  38. Conditional (Boolean) Statements • <Boolean statement> • Can be: TRUE or FALSE • Assemble these together: • if (<>) • { • // do something • }

  39. Put this all into the forever() loop

  40. Making it better? • Add the pen to Scratch so you can track the path of the animation. • Can you draw out your initials with this? • Can you draw a smiley?

  41. Graphical Effects • Play around with the different graphical effects under Looks • Drop the slider control in to add control. • Remember this needs to be inside the forever()

  42. Building a game. • Step 1: Concept design • Step 2: Storyboarding • Step 3: Prototype / Code • Step 4: User beta testing • Step 5: Presentation

  43. Adding other features • Using the slider to control left-right (x position) • Use the button to “jump”

  44. Creating a new costume • Click Copy • Click Edit on the new costume (costume3)

  45. Use the Paint Bucket tool to color in Scratch

  46. When the light level gets dark, change costume • What are the light levels in this room? • After you click the checkbox, you should see this  upper left corner

  47. Setting thresholds • Use the Greater Than \ Less Than Comparison blocks and the if() block to control when your character changes costumes.

  48. Additional Challenges for Today • Use the slider to control the direction of the character. • Use the light sensor, program a sprite to hop up and down whenever a shadow passes by. • Use the slider and button to control a character in a video game. • Use the sound sensor, you can make a sprite change how it looks whenever there is a loud sound. • Other ideas???

  49. What else can Scratch do in my class?

More Related