fabacademy


Since my progress with electronics and programming has not been great, for this week's assignment I decided to simply added an output element to what I made for week 9. I decided to use a buzzer, in order to have another way to know if temperatures are out of the range I need.
The buzzer will emit different sounds depending on the DHT11 sensor's state or data, just like I did with LEDs.

Buzzers are small and cheap speakers that emit sounds at controllable frequencies, they remind a lot of the sound of an old 56k internet modem starting a connection.

Anyway, they are very simple to use. They have two pins, one of which has to be connected to the signal/voltage and one which acts as GND.
Arduino IDE has a precise function (tone()/noTone()) which allows you to decide when the buzzer is on and what frequency it is emitting.

I connected the buzzer to my Arduino through a 100 Ohm resistor and then modified the code you can find in week 9, so that it would emit different sounds depending on the state of the sensor.

blablabla

First I had to assign a pin to my buzzer, then in setup I set the pin as an output.

blablabla

Then I had to decide a pattern for the three "emergency states".
No data received: alternating low and high beep with a small pause.

blablabla





Temperature too low: continuous sound, like a flat ECG.

blablabla

I temporarily changed the temperature range to see if the sound was working in this state.





Temperature too high: regular beeps, red alarm style

blablabla





When we assign the tone function, the duration of the beep will depend on the delay command we give after it.

It is very important to add the noTone command after the tsequence we want, otherwise sound will keep going even if the conditions change.

I also wanted to connect the laser diode module KY-008 that came together with the sensor kit I got.

blablabla

By reading how it works on the internet it seemed quite easy and relatively useless, but it made me speculate on the idea of activating a very powerful laser to point towards the fermentation tank and act as a heater when the temperature is too low.
So I added it to the setup and modified the code again to have the laser activated only in the right condition.



After thinking about the process, if this was a real prototype, I would probably write the code again in order to make it work with millis instead of delay, since it stops the laser every once in a while.

Here you can download the code file