🇩🇰 Sæbedispenserprojekt

🇩🇰 Herunder er beskrivelser og instruktionsvideoer til sæbedispenser projektet. Projektet er udviklet med udgangspunkt i COVID-19 krisen og har til formål at gøre en almindelig sæbedispenser mere hygiejnisk ved at gøre den berøringsløs.




The automatic soap-dispenser, which we will be creating in this project, can be seen in the video below. Notice how and LED is used as a constant light-soruce, for a light-sensor. The dispenser is activated by blocking the light-source, from reaching the light-sensor. When this happens, a servo-motor will push out the soap. You will also notice that the display on the micro:bit, will indicate when the dispenser in ready to be interacted with, as well as when it is currently occupied by dispensing the soap.



Step 1 – The initial setup:

We will use the Dragontail to connect the micro:bits pins to the breadboard.



Step 2 – Connect the Power Booster:

The micro:bit can only supply the breadboard with 3V. But some of our components will be needing 5V. Therefore, we will use the Power Booster to supply it with 5V. Remember, that for this to work, the GND (-) pin on the micro:bit and the Power Booster, must be connected, by a wire.



Step 3 – Setup the light-source:

We will now use a 56Ω resistor and a 5mm White LED, to construct a constant light-soruce. The LED needs 5V, why we will power it with the Power Booster. Remember that electricity can only flow one way through an LED, from the longest leg, to the shortest.



Step 4 – Setup the light-sensor:

We will now construct a light-sensor, using an LDR (Light Dependent Resistor) and a 1KΩ resistor. The light-sensor works by dividing the voltage drop, between the resistor and the LDR, according to the size of their resistance. By connecting a wire between them to pin 0 on the micro:bit, we can use the micro:bit to read the voltage level between them. Since the LDR’s size of resistance varies according to the light, the value we are reading will reflect the level of light which shines upon it.



Step 5 – Test the light-sensor:

To test the light-sensor, we will be using a variable to store the value we are reading from the light-sensor, connected to pin 0. Then we will print the value of the variable to the monitor. Remember, the program can only be downloaded, when the micro:bit is paired with the MakeCode editor.



Step 6 – Combine the light-source and the light-sensor:

To combine the light-source with the light-sensor, we will bend the LED and the LDR towards each other. By doing this, the light-sensor will have its own light-source. This will prevent it from being influenced by changes to the light-level inside the room. 



Step 7 – Test the combined light-source and light-sensor:

To test the combined light-soruce and light-sensor, we can use the same program as in step 5, to read the new values of our light-sensor. Try to break the light-source with a finger. Write down the values for when the light-source is broken, and for when it is not broken.



Step 8 – Setup the servo-motor:

We will use a servo-motor to push out the soap. Since the Servo-Motor needs to be powered by 5V, we will connect it to the Power Booster. In order for us to control it, we will connect it to pin 16 on the micro:bit.



Step 9 – Reset the servo-motor:

The servo-motor can only rotate 180o. We will therefore first reset it to position 0o and then screw on the tap. Remember, that when the servo-motor is in position 0o, the tap needs to point directly upwards.



Step 10 – Programming the dispenser:

We will now write the full program, for automating the dispenser.

  • Use the “V” icon, to indicate that the dispenser is ready for interaction.
  • Create a variable, to store the value from the light-sensor, and print the value to the monitor.
  • Create a conditional with a statement that returns true, if the light-level is lower than 500 (the average of your lowest and highest number from step 7).
  • Use the “X” icon, to indicate that the dispenser is not ready for interactions.
  • Turn the servo-motor to position 180o, and give it 2 seconds to reach the position.
  • Turn the servo motor back to position 0o and give it 2 seconds to reach the position.

Remember to test the program on the hardware, before moving on to the next steps.



Step 11 – Attach the servo-motor:

Glue the servo-motor to the dispenser. Remember, the servo-motors tap, have to be moving away from the dispenser.



Step 12 – Attach the top straw:

Glue a piece of straw on the top of the dispenser.



Step 13 – Attach the string:

Tie a piece of string to the servo-motor, then run it through the piece of straw on the top of the dispenser. Now, tie another piece of straw at the other end of the string, and glue that piece to the dispenser. Remember, the string must be tight.



Step 14 – Test the finished project:

Congratulations, you have finished the project and made a fully automatic, super-duper and hygienic soap-dispenser. Great work! 😀