agsdix-fas fa-child

Variable intensity lamp

How can you adjust the intensity of a lamp? Let’s create a lamp that changes intensity based on the movement of a knob and see how it works.

Info Outline Icon
Basic Activity; Potentiometer; Events; Colors; Grayscale Scale.

What are we going to do?

Are you a teacher?

Lesson Plan

Courses

  • Grades 3-12
  • 3rd Grade – 12th Grade Courses

Materials

  • Cellphone, tablet, or computer
  • Internet connection

Description

In this activity, students can experiment in an introductory manner with Protobject, learning visual programming and computer science safely and playfully with a device.

Educational Objectives

  • Understand the concepts of events and potentiometer.
  • Create a technological object (prototype) using a device.
  • Identify relationships between technology and the world around them.
  • Evaluate their own work and that of others, individually or in teams.
  • Engage in dialogue and reflection on improvement ideas.

Introduction (10 minutes)

Welcome students to the class and briefly introduce the day’s activity: “Today, we will learn how to prototype a lamp with variable intensity.”
We will start the class by providing students with the technical background necessary for the meaningful learning of the practical activity.
To kick off the class, we can start with a question:
Do you think colors appear the same on print as they do on a screen?

You can give students the floor to propose their answers and then complement with the correct answer.
Subtractive synthesis and additive synthesis are two different ways of mixing colors and creating new ones.
Subtractive synthesis is primarily used in paper printing, such as books, newspapers, magazines, etc. When we look at a colored object, we are actually seeing the color it reflects and absorbs. For example, if we see a red object, it means it is absorbing all colors except red, which it reflects.
In subtractive synthesis, we start with a white light source (containing all colors) and use colored inks or pigments to absorb some of the colors and reflect others. So, if we mix different colored inks, the amount of reflected light decreases, and the perceived color changes. Mixing all color inks (cyan, magenta, yellow) together, they absorb almost all colors and reflect only a little light, resulting in black.
On the other hand, additive synthesis is used in creating images on electronic screens, like TVs, computers, and mobile phones. In this case, the light source comes from the screen’s pixels and adds up to create colors. If we add all colors together (red, green, and blue), we get white light.
In additive synthesis, different shades of gray can be created by mixing different amounts of light from the primary colors: red, green, and blue. If we want to create a darker gray, we can reduce the intensity of the primary colors on the screen, reducing the total amount of emitted light and resulting in a darker gray. Conversely, if we want to create a lighter gray, we can increase the intensity of the primary colors, increasing the total amount of emitted light, resulting in a lighter gray.
Black corresponds to the absence of light and is achieved by turning off all primary colors (red, green, and blue). On the other hand, white is achieved by adding the maximum amount of light from the primary colors, which means all primary colors are at their maximum.
So, we can create different shades and hues of colors and grays on a screen by manipulating the quantity and intensity of light emitted by the primary colors.
Do you remember what a potentiometer is?
You can give students the opportunity to propose their answers, and then complement with the correct answer.
A potentiometer is a component, usually with a knob, used in electronic circuits to control the amount of electricity flowing through a wire. A potentiometer can be used, for example, to adjust the volume of a radio, or even, you can adjust how much electricity reaches the pixels of the primary colors on the screen to make them darker or lighter!
In this case, by turning the potentiometer to one side, the screen will display a darker gray, all the way to black, and by moving it to the other side, it will display a lighter gray, all the way to white.
With Protobject, we can simulate a potentiometer on the smartphone screen so we can use it to control the amount of emitted light to create different shades of gray.
Finally, to kickstart the prototyping process and make them feel like the protagonists of their learning, ask them:
Do you want to learn how to prototype a lamp with variable intensity?

Development (20-30 minutes)

We connect our device to the Protobject platform. For this exercise, we will use LAMP and SIMPLEKNOB.
Remember to experiment beforehand by yourself before asking the students to experiment with Protobject so that you can anticipate questions that may arise from the students.
First, we will activate the knob with the SIMPLEKNOB block to tell it what to do when the knob changes.
Now, we will tell it what to do with the LAMP turn-on block, assigning the colors red, green, and blue and having them change when the knob is turned.
Since they all change in the same proportion, we will obtain different shades of gray.
To test the prototype, we will instruct the students to click on the activation button.
Congratulations!

Closure (5-10 minutes)

Now that you have prototyped a lamp with variable intensity using Protobject, introduce the next topic to your students with a question:

  • How would you adjust the intensity of a red, green, or blue light?

To solve the challenge presented, it is necessary to add a conditional and evaluate the knob’s rotation with each event. If it exceeds 80, music will play. Otherwise, it should be turned off. If this is not done, the music will never stop!
Check the challenge solution.

agsdix-fas fa-book-reader

Learn

Do you think colors appear the same in a print as they do on a screen?

Subtractive synthesis and additive synthesis are two different ways of mixing colors and creating new colors.

Subtractive synthesis is primarily used in paper printing, such as in books, newspapers, magazines, etc. When we look at a colored object, we are actually seeing the color it reflects and absorbs. For example, if we see a red object, it means it is absorbing all colors except red, which it reflects.

In subtractive synthesis, we start with a white light source (containing all colors) and use colored inks or pigments to absorb some of the colors and reflect others. So, if we mix different colored inks, the amount of reflected light decreases, and the perceived color changes. Mixing all color inks (cyan, magenta, yellow) together, they absorb almost all colors and reflect only a little light, resulting in black.

On the other hand, additive synthesis is used in creating images on electronic screens, such as TVs, computers, and mobile phones. In this case, the light source comes from the screen’s pixels and adds up to create colors. If we add all colors together (red, green, and blue), we get white light.

Additive Synthesis and Shades of Gray

In additive synthesis, different shades of gray can be created by mixing different amounts of light from the primary colors: red, green, and blue. If we want to create a darker gray, we can reduce the intensity of the primary colors on the screen, which will decrease the total amount of light generated by the screen, resulting in a darker shade of gray. On the other hand, if we want to create a lighter gray, we can increase the intensity of the primary colors, which will increase the total amount of light generated by the screen, resulting in a lighter shade of gray.

Black corresponds to the absence of light and is achieved by turning off all primary colors (red, green, and blue). On the other hand, white is achieved by adding the maximum amount of light from the primary colors, which means all primary colors are at their maximum.

In this way, we can create different shades and nuances of colors and grays on a screen by manipulating the quantity and intensity of light emitted by the primary colors.

Potentiometers for controlling shades of gray

Do you remember the potentiometer?

A potentiometer is a component, typically including a knob, used in electronic circuits to control the amount of electricity flowing through a wire. A potentiometer can be used, for example, to adjust the volume of a radio, or even to fine-tune how much electricity reaches the pixels of the primary colors on the screen, making it appear darker or lighter!

In this case, by rotating the potentiometer to one side, the screen will display a darker gray, eventually reaching black. By turning it the other way, it will display a lighter gray, eventually reaching white.

With Protobject, we can simulate a potentiometer on the smartphone screen to control the amount of light emitted, creating different shades of gray.

Let’s get to work!

This time, we will use the potentiometer with the aim of modifying the intensity of a lamp. First, we will define the range within which the potentiometer will operate and how its reading will be converted into the intensity of light. Then, we will use this variable in the lamp to adjust its brightness according to the set value.

Prototipar

Let’s create the prototype to control the light.

The first step is to add two devices that allow us to (1) simulate a light on the screen and (2) simulate a potentiometer.

1

Press Add Device, select Lamp, and press Open in This Window to open the lamp on the computer.

2

Press DevicesAdd Device, select Knob, and scan the QR code with your smartphone to generate a potentiometer on the screen.

We are ready to start prototyping!

Code composition

Click on question circle icon to open the comments that explain the code.

The color handling blocks can be found in the Color category.

Remember: In this project, we can replace the event with the main loop.

agsdi-bulb-options

Reflect

Now that you’ve learned how to control a light with a knob:

How would you go about adjusting the intensity of a red, green, or blue light?

plus square icon

Challenge: Modify the project so that when the potentiometer exceeds the value of 80, a song is played.

Hint: Add the component to SoundPlayer to play the song, and check the value of the potentiometer with a conditional. If the potentiometer exceeds the value of 80, then play the song, otherwise stop the song.