Back to Parent

Outcome


Using a pushbutton

Turn a light on and off using a pushbutton.

0.thumb
Show Advanced Options
Show Advanced Options
Show Advanced Options

Using a switch

Turning light on and off through a switch.

1.thumb
Show Advanced Options
Show Advanced Options
Show Advanced Options

Using a potentiometer

  Fade up and down an LED as you turn the dial.  
2.thumb
Show Advanced Options
Show Advanced Options
Show Advanced Options

Combining a switch and potentiometer

  The switch should turn on and off the light while the potentiometer will fade up and down the light (but only when its on).  

3.thumb
Show Advanced Options
Show Advanced Options
Show Advanced Options

Using a photoresistor

  The program shows how much light is available. When there is lots of light the LED is bright. When there is little light it’s dim.    

5.thumb
Show Advanced Options
Show Advanced Options
Show Advanced Options

Exercise 1:

Modify the program so that the LED shows the opposite. When there is little light, it will be bright and when there’s lots of light, it will be off.  
Show Advanced Options
Show Advanced Options

Exercise 2:

  Turn the light on and off when reaches certain levels. If the light levels are below 600 turn the light on (and bright), otherwise turn it off.    

Show Advanced Options
Show Advanced Options

Practice Exercise:

if the button is pressed: the led will react with the lightness of outside world

The stronger the outside light is, the weaker the light intensity of LED will be

If the button is not pressed, nothing will happen

6.thumb
Show Advanced Options
Show Advanced Options
Show Advanced Options

Process & Reflections

I think it's very interesting to understand how sensors and controllers work. One thing is important is to know the difference between analogRead/Write and digitalRead/Write. There is no such method as digitalRead but we set pinMode to do that. By thinking about we need a boolean value or a value in range, I'm more confident with writing codes. By the way, map() is a good method to change value range. And remembering the electrical connection of all kinds of sensors and controllers is really important!

Drop files here or click to select

You can upload files of up to 20MB using this form.