PROJECT Nº 5: Automatic paper dispenser

Learn to build and program an automatic paper dispenser using the components of the Maker Control Kit and Maker Kit 2.

Use the DC motor with a propeller and the IR line tracking sensor to create a system that automatically dispenses a bit of paper, without pressing any buttons. Simply put your finger in front of the IR line tracking sensor and surprise people with your automatic paper dispenser.

DIFFICULTY LEVEL: Beginner.

DURATION OF THE EXERCISE: 75 min.

MATERIALS:

  • 1 DC motor with propeller
  • 1 Line follower IR sensor
  • 1 4in1 Build&Code board
  • 1 USB – Micro USB cable
  • Computer
  • Material for the structure
  • Adhesive or tape

BUILDING THE STRUCTURE:

For building the paper dispenser you will use thick cardboard, sheets of paper, bottlecaps, and tape. Download the quick setup guide and follow the steps shown:

  1. Disassemble the motor propeller and take out the plastic film of which the propeller is made. Reassemble the yellow joint piece and fit it in the DC motor shaft.
  2. Make a cylinder with the sheet of cardboard that has the same diameter as the yellow joint piece of the DC motor with a propeller. Fit one end of the plastic sheet with a cap and the opposite end with a layer of tape.
  3. On the end with tape, insert the yellow piece of the DC motor with a propeller, along with the motor.
  4. Divide and cut out 3 strips of paper 5 cm wide and connect them to create a single strip of paper. Fasten the strip of paper to the cylinder you made and roll it up.
  5. To finish, connect the DC motor and the IR line tracking sensor to the 4in1 Build&Code board, following the indications in the section on connection found below.

Put the entire system on an elevated surface, like a box. The roll of paper should come out of one end of the box, such that it can turn freely.

CONNECTIONS:

  1. Connect the DC motor with a propeller to digital port 9 on the 4in1 Build&Code board.
  2. Connect the line follower IR sensor to digital port 5 on the 4in1 Build&Code board.

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

PROGRAMMING CODE:

The program activates the DC motor with a propeller for only 0.5 seconds when the IR line tracking sensor receives a signal, so that the system dispenses just a bit of paper. To achieve this, the code that we will use includes a status counter.

The IR line tracking sensor will receive the signal when you put your finger over it, and the value registered will change from 0 to 1. Depending on the code, the DC motor with a propeller will activate for 0.5 seconds and dispense a bit of paper when the value of the IR line tracking sensor and the value of the status counter are 1.

If you do not put your finger over the IR line tracking sensor, it will not receive a signal. That is, the DC motor will stay off and not dispense any paper.

However, the status counter will stay at the 1 value, so that when it receives the value of 1 again from the IR line tracking sensor (that is, when you put your finger in front of the sensor again), the DC motor with a propeller will turn and dispense a bit of paper.

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.
  2. Open the Arduino program, and once in, copy the following program:
    /* MOTOR*/
    int PMotor = 9; // DC motor connected to digital port 9
    /* SENSOR IR*/
    int PSIR = 5; // Line follower IR sensor connected to digital port 5
    int StatusIR = 0; // Variable of the state of the line follower IR sensor
    /* Variables*/
    int Status; // Status variable.
    
    void setup() {
      // Put your setup code here, to run once:
      pinMode(PSIR, INPUT); // IR sensor is configured as input
      pinMode(PMotor, OUTPUT); // DC motor is configured as output
    }
    
    void loop() {
      // Put your main code here, to run repeatedly:
      StatusIR = digitalRead (PSIR); // Value reading of the line follower IR sensor
      if ((StatusIR == 1)&&(Status == 1)) // If the IR sensor and the status variable are equal to 1
      {
        analogWrite (PMotor, 100); // DC Motor = ON at a speed of 100
        delay(500); // 0.5 seconds
        analogWrite (PMotor, 0); // DC Motor = OFF
        Status = 0; // Status variable = 0
      }
      if (StatusIR == 0) // If the IR sensor is equal to 0
      {
        analogWrite (PMotor, 0); // DC Motor = OFF
        Status = 1; // Status variable = 1
      }
    }
    
  3. Configure and load the code, following the instructions given in the document First Steps for the 4in1 Build&Code board.

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 document First Steps for the 4in1 Build&Code board.

BitBloq Code

  1. Get the BitBloq software.
  2. Open the BitBloq program, and once in, copy the following code:
    • Hardware
    • Software
  3. Configure and load the code, following the instructions given in the document First Steps for the 4in1 Build&Code board.

RESULT OF THE EXERCISE:

If you cover the IR line tracking sensor with your finger, the DC motor with a propeller will be activated and the system will dispense a bit of paper. You have created your own automatic paper dispenser!

1 0

0