PROJECT Nº1: Lamp with a button

Learn to build and program a lamp that turns on at the push of a button, using the components of the Maker Control Kit.

For this project, you will use the button and the white LED. Press the button to turn on the lamp, and let it go to turn it off. Get your first invention going!

LEVEL OF DIFFICULTY:  Beginner.

DURATION OF THE EXERCISE: 30 min.

MATERIALS:

  • 1 Button
  • 1 White LED
  • 1 4in1 Build&Code control board
  • 1 USB – Micro USB cable
  • Computer
  • 1 Clear or white plastic cup
  • Material to make the lamp structure
  • Adhesive

What is an LED?

An LED is a semiconductor electrical component (diode). When a small current passes through it, the diode emits light.

CONNECTIONS:

  1. Connect the white LED to digital port 9 on the 4in1 Build&Code control board.
  2. Connect the button to digital port 4 on the 4in1 Build&Code control board.

Look at the colors of the cables and the colors of the terminals on the 4in1 Build&Code control board to guide you. Each cable should be connected to its color.

BUILDING THE STRUCTURE:

To build the lamp structure, you will use 150 mm x 18 mm wooden sticks, a clear or white plastic cup, and hot silicone to make all the structure’s joints. Download the quick setup guide and follow the steps shown.

PROGRAMMING CODE:

The program makes the white LED turn on when you push the button, and when the button is not pushed, the white LED stays off.

You can do this activity by using Arduino and Bitbloq software, as well as other compatible block programming software. Below you will find the programming code needed for each software.

Arduino Code

  1. Download the Arduino software and go through the installation process.
int PLED = 9; // White LED connected to digital port 9
int PButton = 4, ValueButton; // Button connected to digital port 4. Button reading variable

void setup() {
  // put your setup code here, to run once:
  pinMode (PLED, OUTPUT); // Configuration of the LED as output signal
  pinMode (PButton, INPUT); // Configuration of the button as the input signal
}

void loop() {
  // put your main code here, to run repeatedly:
  ValueButton = digitalRead(PButton); // Button status reading
  if(ValueButton == HIGH) // If the button is pushed
  {
    digitalWrite(PLED, HIGH); // LED = ON
  }
  else // If the button is not pushed
  {
    digitalWrite(PLED,LOW); // LED off
  }
}

Code for compatible block programming software

  1. Download the software and go through the installation process.
  2. Open the program, and once in, copy the following code:                                                                                                             
  3. Configure and load the code, following the instructions given in the First Steps for the 4in1 Build&Code board document.

BitBloq Code

  1. Get the BitBloq software.
  2. Open the BitBloq program, and once in, copy the following code:
    • Hardware
    • Software

RESULT OF THE EXERCISE:

You have built a lamp that turns on at the push of a button. When you let go, the lamplight will turn off.

Congratulations, you have created your first project!

0 0

0