Midterm Project
- colleenguirand1
- Oct 20, 2021
- 2 min read
For my midterm, I created a fake home security system. I used sensor wires to detect when "someone" crosses through the front door, a speaker to project the "alarm" sound, and LED lights to visibly show what is going on.
Steps to code:
First, I set all variables that I was planning on using (buttonValue- for buttons A+B, irSensor) to zero. Along with variables, I had to set my pull pin 8 to up to activate my sensor.
After, I laid out the conditions for what my sensor was supposed to do. The plan was if the sensor is not interrupted by "anyone" or object, the LED lights would stay off since no one is intruding the home. So I set the variable to the pin I was intending on using (pin 8) and said if the sensor is 1 or off in this case, all LED will be off. Then I said if it is at zero or off, then the lights would turn on along with a sound to play once and sting of text.
After the person breaks sensor beam, a password must be placed. In my project, both buttons A+B pressed together would be considered the password. So in that block, I created statements saying when both buttons are pressed, turn off all sounds and play a ba ding sound to confirm password success. if else, don't make a sound.
Lastly, I created two separate blocks to show what will happen when both a and b are pressed separately.
The functionality in the project works, but I have to press both buttons A+B together multiple times for the microbit to read that the password has been "activated". During this time the microbit figures that out, the sound is continuing in a loop and it gets annoying, maybe because I had the nyan sound in the forever loop. Also, I am not sure if the sensor is wired correctly, but regardless if someone steps in or not the sound goes off


Comments