Week 4 – Opening and Closing Door – TWE

The chosen way to demonstrate the sound sensor module and the Bluetooth sensor was a doorbell and door. When the doorbell activates and makes a sound it’s detected by the sound sensor module, which in turn activates the Bluetooth sensor to send a notification to a Bluetooth device (in this case a mobile phone). The phone displays that a sound has been detected and gives the option whether to activate the servo (or door) or not.

Arrange Arduino and Breadboard as shown:

Sound+Bluetooth2

Equipment Required:

-1x Arduino UNO

-1x Breadboard

-1x Sound Sensor Module

-3x 2200 ohm Resistor

-1x Bluetooth Sensor

-4x Cables (Female – Male)

-.11x Cables

Input the code below:

https://create.arduino.cc/editor/tomelwes/d1a1540e-60bf-489d-a8ce-022b1f8967a9/preview?embed

attach – Attach the Servo variable to a pin. Note that in Arduino 0016 and earlier, the Servo library supports only servos on only two pins: 9 and 10.

detach – Detach the Servo variable from its pin. If all Servo variables are detached, then pins 9 and 10 can be used for PWM output withl analogWrite(). This command detaches the servo from the circuit

These commands were used because the servo would move unexpectedly due to its sensitivity alongside the sensitivity of the

Advertisements

Week 3 – Project Ideas – TWE

Ideas that integrate both a Sound sensor and a Bluetooth sensor:

Sound Sensor = Input

Bluetooth Sensor = Output/Input

LED Display Screen = Output

Servo = Output

Ideas:

Game – Make as much noise as you can to trigger something in the phone. A score board of noise possibly.

img081

Sound detector – Shows the sound levels visually and on a phone e.g. Baby Monitor?

img080

Door Bell Detector – If door bell sound is detected it will send a message to a Bluetooth device, and from your device can choose to open or keep the door closed.

img082

Using the “if” statement to send data via Bluetooth to trigger a function on the phone or other Bluetooth device. For example, making a low-level sound triggers one action while a higher level of sound will trigger another action, and so on and so forth.

The “if” statement checks for a condition and executes the proceeding statement or set of statements if the condition is ‘true’.

So if (sound > 31) {

digitalWrite(led1, HIGH);

}

if (sound < 31) {

digitalWrite(led1, LOW);

}

 

 

Idea 1:

Have a small object with the sound sensor within which flickers to the different sound levels and sends a message to a Bluetooth device, like a text message at different sizes to show the sound levels or a certain image to represent the level of sound

Idea 2:

Make a loud enough sound into the sound sensor module, which will send data to a Bluetooth speaker, which will make a noise back at you. Certain catchphrases for each level of sound.

HC-06 and Arduino (includes simple project!)

I have been given HC-06 Bluetooth module and a stepper motor from the lecturer to explore. Both of them are extremely interesting and fun to play with, but I decided to write about HC-06 since this module allows me to make much more interactive projects. Now let me explain briefly what it is.


HC-06 is a very popular and inexpensive module that uses serial communication via Bluetooth. It allows us to wirelessly communicate between Arduino and any Bluetooth device, such as laptop, Android or iOS device. HC-06 can receive and send data to the device that is paired and connected. However, HC-06 can only accept a connection from outside, it cannot initiate one. It means it can only work as a SLAVE.

MASTER and SLAVE

The device that is able to initiate the connection is called MASTER. There are Bluetooth modules that can be both MASTER and SLAVE, for example HC-05. Those properties the given by the manufacturer and they cannot be changed via AT commands.

AT mode

AT command mode allows you to interrogate the Bluetooth module and to change some of the settings:

  • the name
  • the baud rate
  • operation in slave mode or master mode. (HC-05 ONLY)
  • etc.

It is not needed now, but is you want to read more about AT mode and the commands, see further reading section at the bottom of the site.

Connection

HC-06 can be supplied by a range of 3.6 – 6V. That means it can be connected straight to the Arduino. However, the input (RXD) and output (TXD) pins operate on 3.3V. For the output it is fine to connect it straight to the Arduino since the microcontroller will recognize 3.3V as HIGH signal. But Arduino outputs the signal of 5V, therefore it is essential to put a voltage regulator or a 1kΩ resistor to ensure that HC-06 will not be damaged.

Project! (simple)

I decided to share with you this simple project of wirelessly controlled LED lamp. It uses HC-06 to receive data from the Android device, serving as a wireless ON/OFF switch. let’s see the scheme of the circuit and let me explain it briefly:

BT_LED_HC-06_bb

It is a very simple setup. D13 goes to the LED with 500Ω resistor, it will be our lamp. D11 goes into the RXD (the input of the HC-06) not that I used a 1kΩ and a 2kΩ resistor to lower the voltage. D10 goes into the TXD (output), GND to GND, and 5V to power up the HC-06.

Even though physical serial ports of the Arduino are on the D0 and D1 pin, I decided to use a SoftwareSerial library to create a digital serial port for my HC-06. Otherwise, when using the original ports, I would not be able to upload my code via USB, as HC-06 would “steal” my serial connection.

Code is here: https://create.arduino.cc/editor/BecNoir/c025de4d-1a0b-4e1d-8f55-c96d97f5df8f/preview?embed

As you can see, I set up the device to read the input from my Android phone. How do I do that? I just simply need any serial monitor app from the Goggle Play. You can find the one I’m using here. In order to use the app, I need first to pair my phone with the HC-06, I should be able to find it in the list of Bluetooth devices. The password to pair is commonly 1234. After that I just need to select my device in the serial monitor app.

A video of working circuit is here:

Next time I will try to combine HC-06, sound sensor and a servo in a group project with Thomas!

References and further reading:

Happy creating!

Bec

First mini project – Dice simulator

Hi! I am back from playing with the Arduino for a couple of days. As I mentioned in previous post I wanted to do something with the LEDs. Since I am more ambitious than making a simple blinking light (which I made obviously as my very first circuit and coding), I looked for some inspiration. What interactive can I make out of LEDs?

When looking at the tabletop board games I just got an idea of what can be made. A LED dice simulator!

white-six-sided-dice

A single D6 has got 6 outcomes: from one to six. Quite obvious. and they look like in the photo below.

dice-clipart-domino-7

If I want to create an LED version of all possible faces of a dice, I need 7 LEDs in total:

  • 3 LEDs on the right and left side, vertically in line, total of 6
  • 1 LED in the middle

At a first glance it looked like I need 7 digital pins to connect each LED to Arduino separately! Well, that’s a lot for such a simple project. Therefore I thought about a way to reduce amount of pins needed.

As I took a closer look at each face of the dice, there are patterns that are easy to reproduce using a series of 2 LEDs. This simple drawing of a circuit below should explain it.

DIEsim001.jpg
A quick draft of a LED series. I used 560 Ω resistors.

I created 4 groups of LEDs. 3 of them (G1, G2, G4) consists of 2 LEDs in series that will light up simultaneously when powered up. One group (G3) is a single LED in the middle. With those groups you can still create every face of a dice using only 4 digital pins. Let me show you all the sequences:

  • result = powered group(s)
  • one = G3
  • two = G1 or G4
  • three = G3 and (G1 or G4)
  • four = G1 and G4
  • five = G1 and G3 and G4
  • six = G1 and G2 and G4

I also wanted to have a button that would serve as a rolling button. So whenever you press the button, the LEDs will light up in one of those sequences.

I built a circuit that looks like this:

DICE_simedit.jpg

That’s a lot of jumper wires, one would say. But after brief testing every LED group works as intended.

As you can see, groups of LEDs are connected to the D10 – D13, and the button input is connected to D2. Make sure to use a high resistor at the output of the button to avoid random activation of the LEDs (I used a 10kΩ resistor).

Now, coding time! Code for the dice simulator is very simple, it just consists of many if statements.

https://create.arduino.cc/editor/BecNoir/d0f922fa-719c-4cf6-a8d3-3bf3b5b1b149/preview?embed < click to access code!

Mini FAQ:

Q: Why random(5); instead of random(6);?

A: In programming, logically, zero is the first number not one. So when you random(5); you are actually randomizing 6 numbers between 0 and 5.

Video of working dice simulator:

If you want to read more about relevant functions used:

My next mini project will probably involve a module or a motor! Stay tuned for the next post!

Happy Creating!

Bec

Week 2 – Sound Monitor – TWE

Using certain code to allow certain LEDs to light up at certain sound levels to be used as a sound monitor.
Different LEDS Lighting up depend on the sound level:
Arrange Arduino and Breadboard as shown:

Sound Monitor Diagram
Equipment Required:
-1x Arduino UNO
-1x Breadboard
-5x LEDs
-5x 560 ohm Resistor
-11x Cables
-4x Cables (Female – Male)
-1x Sound Sensor Module

Input the codde below:

https://create.arduino.cc/editor/tomelwes/85ababc2-9139-4e49-846c-10f9d37fc088/preview?embed

Once the code is uploaded bring up the serial plotter and check the numbers shown. This code has the range from 0-50, so adjust the Sound sensor to around 30 as the first value shown is “if (sound >31).

You can change the values in the code, but it means they must the match the sensitivity.

The const keyword in “const int” stands for constant. It is a variable qualifier that modifies the behavior of the variable, making a variable “read-only”. This means that the variable can be used just as any other variable of its type, but its value cannot be changed. You will get a compiler error if you try to assign a value to a const variable.

Constants defined with the const keyword obey the rules of variable scoping that govern other variables. This, and the pitfalls of using #define, makes the const keyword a superior method for defining constants and is preferred over using #define.

Sound Monitor 2

References:

https://www.princetronics.com/sound-sensitive-lights-w-sound-sensor-arduino/

https://engmousaalkaabi.blogspot.co.uk/2015/10/sound-level-detector-using-arduino-and.html

https://www.youtube.com/watch?v=lsW3upcvsxg&t=431s&index=8&list=PLogJx9cUrggjGgJGKQiZb2ZG2POGn92pN

https://www.dropbox.com/s/6q77ettv93vdvcj/Microphone.rar?dl=0

https://www.arduino.cc/reference/en/language/variables/variable-scope–qualifiers/const/

Week 1 – Sound Sensor Module – TWE

Sound sensor moduleSound sensor module 2

The sound sensor module provides an easy way to detect sound and is generally used for detecting sound intensity. This module can be used for security, switch, and monitoring applications. Its accuracy can be easily adjusted for the convenience of usage. It uses a microphone which supplies the input to an amplifier, peak detector and buffer. When the sensor detects a sound, it processes an output signal voltage which is sent to a microcontroller then performs necessary processing.

Sound sensor module has 2 outputs. AO – analog output, real-time output voltage signal of the microphone. DO – the digital output depends on the sound intensity and the threshold that has been set. (Arduino® VMA309 A0 A0 GND G +5 V + D0).

Voltage – 3.3-5 VDC
Outputs – One analogue + One digital output
Fixation – 1 x mounting screw hole (3 mm) 2 indicator
LEDs – 1 power indicator + 1 comparator output indicator frequency
Response – 50 Hz – 20 KHz impedance
– 2.2 kΩ sensitivity
– 48-66 dB operating

Specifications:

Parameter Value
VCC 5 Vdc from your Arduino
Ground GND from your Arduino
Out Connect to Digital Input Pin
Power LED Illuminates when power is applied
Sound Detection LED Illuminates when sound is detected
Sound Set Point Adjust CW = More Sensitive
CCW = Less Sensitive

Blinking LED reacting to Sound:

Arrange Arduino and Breadboard as shown;

Sound sensor module Diagram

Equipment Required:

-1x Arduino UNO

-1x Breadboard

-1x LED

-1x 560 ohm Resistor

-8x Cables

-1x Sound Sensor Module

https://create.arduino.cc/editor/tomelwes/849478ec-af04-486c-8180-d5f404a13c29/preview?embed

Once code is uploaded bring up the Serial Monitor or plotter and check the numbers. Adjust the sound sensor pin to the desired sensitivity. Around 500+ usually is an optimal sensitivity for this project.

Sound Blinker 2

References

http://osoyoo.com/2015/03/20/sound-sensor-module-project/

http://henrysbench.capnfatz.com/henrys-bench/arduino-sensors-and-input/arduino-sound-detection-sensor-tutorial-and-user-manual/

http://tinkbox.ph/sites/mytinkbox.com/files/downloads/SOUND_SENSOR_MODULE.pdf

https://www.robotshop.com/media/files/pdf/sound-sensor-module-arduino-datasheet.pdf

The beginning of an Arduino journey

Hi! Welcome to my first blog entry! My name is Lukasz Staszewski, but I will be posting under my alias: BecquerelNoir. This blog will be themed around the popular microcontroller Arduino and any my problems, solutions and other encounters while working with it.

I got my Arduino experimentation kit from the university. It features all the basic equipment that I need to start playing with it – bunch of jumper cables, range of resistors, LEDs, a DC motor, a basic servo, potentiometers, buttons etc. I would not say that is a lot of stuff, but that is more than enough to start from scratch.

Arduino_kit

Just from looking at the kit I am more and more excited to try it out! Since I have some previous knowledge about coding (C# in simple Unity games), it should be easy for me to settle into the Arduino integrated development environment (IDE). I am already thinking about creating something nice with some of the LEDs I got. I need to watch a couple of simple projects to get inspired to make it!

I highly encourage you to visit those sites to get more information about Arduino:

See you soon!

BecNoir