Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Scratch Cookbook

You're reading from   Scratch Cookbook If want to get your programming know-how off the starting blocks in a fun, involving way, then this guide to Scratch is perfect. In no time you'll be building your own interactive programs that include animations and sound.

Arrow left icon
Product type Paperback
Published in Jul 2013
Publisher Packt
ISBN-13 9781849518420
Length 262 pages
Edition 1st Edition
Languages
Concepts
Arrow right icon
Author (1):
Arrow left icon
Brandon Milonovich Brandon Milonovich
Author Profile Icon Brandon Milonovich
Brandon Milonovich
Arrow right icon
View More author details
Toc

Table of Contents (17) Chapters Close

Scratch Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
1. Getting Started with Scratch FREE CHAPTER 2. Storytelling 3. Adding Animation 4. Basic Gaming 5. Spicing up Games 6. Bringing in Sound 7. Integrating PicoBoards 8. Programming to Calculate 9. Project Remixing Collaboration Index

Integrating the light sensor


The light sensor, pictured in the following figure, can detect changes in the amount of light nearby. We can use the sensor for doing things such as detecting shadows or increase in light.

Getting ready

In this recipe, we are going to explore working with values from the light sensor. We will make a simple program where the sprite brightness will correspond to the amount of light coming into the light sensor.

Keep in mind as we go through this recipe, the light sensor returns values similar to the slider. Values will range from 0 to 100, 0 representing no light.

How to do it...

Let's get started with some steps that will get us there.

  1. Open up a new Scratch file. As always, you can customize the sprite or background to match your preferences.

  2. Drag over a block.
  3. Insert a forever loop directly below this top hat block.

  4. Drag over the block from the Looks category, and you'll have:
  5. Change the effect selected to be brightness by clicking on the drop-down arrow in the block...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image