During the past few weeks, I spend some time playing within Arduino StarterKit creating very simple and basics schemes and refreshing my memory about schematic and different components used in various PCBs.
Created schemes:
Active buzzer
Tilt bolt switch
Ultrasonic sensor
Temp and humidity sensor
LCD
IR remote/receiver
If u interested in environment configuration for working with Arduino, check out my previous post about it.
Active buzzer
A buzzer - is a simple component that can generate sounds with various frequencies. Buzzers are used a lot in different electronics - from toys to PC.
There are 2 types of buzzer - active and passive.
An active buzzer has a built-in oscillating source, so it will make sounds when electrified. But a passive buzzer does not have such a source, so it will not tweet if DC signals are used; instead, you need to use square waves whose frequency is between 2K and 5K to drive it. The active buzzer is often more expensive than the passive one because of multiple built-in oscillating circuits. source
This is a quite simple scheme and u can find a lot of samples for it like this or this
I didn’t reinvent the wheel and just create one of basic scheme:
To make things a bit more interesting, I used this scheme to play a melody from StarWars - The Imperial March (Star Wars, Darth Vader Theme).
To do this, we should do next:
define notes - this was already done and available on official site
12 is a number for a pin, to which connected + from the buzzer.
We also should define noteDuration - this can be figured out from the note’s list obtained from prev steps. We define this as a set of integers, that represent part of a period:
u may also use a stopwatch as alternative
melody - is a set of notes according to note’s list:
If u want to get silence - use 0
I didn’t play on a piano, so I used this resource to figure out how this works.
So the rest - is just a mechanical work:
I know, that timing is not ideal, and I can’t play 2 notes simultaneously using this approach, but this is just a small deviation.
If u like an idea about buzzer song - visit this git for getting more songs
Tilt bolt switch
This component is like a simplified accelerometer - it can detect orientation change. Unlike accelerometers, the tilt sensor is smaller, inexpensive, consume less power, but provide less sensitive result.
Inside, this component usually has a conductive ball with free mass. One end of the cavity has conductive elements (poles). When a sensor is oriented in some way, the mass rolls onto poles and shorts them, it acts as a switch.
The simplest way to test is to detect switch and, for example, light the diode.
The scheme and photo:
And the code:
As result, we can see diode blink when we change oprientation for the component:
Ultasonicsensor is a great component for simple processes that need measurement of the distance. HC-SR04 - this is a inexpensive component that is easy to configure and use. It’s povide quite good result within small distances (up to 4m) within small angle:
Accuracy according to spec is about 2mm.
The principle of work:
using IO we should generate at least 10us high-level signal
module sends 8x 40kHz and detects any puls signals back
if the signal received, calculate distance based on signal return delay, speed of signal
velosity of sound - 340m/s,
division for 2 needed because sound travels forward and back.
The scheme is very simple:
And photo of assembled one:
The code, that reflect this measurement canbe as follow:
Temp and humidity sensor is another cool sensor that can be used in your project. It’s accurate and small and provides the necessary information required by most applications that need it.
LCD is present in the biggest part of electronic devices and allows users to see information or control work it. I tested LCD with a backlight and 2 rows with 16 characters each.
LCD has build in table with symbols - check tech spec for more info. We also can create our own symbol by simply providing mask:
The display has few contacts, the list with contact number and purpose is listed in the table below:
contact #
mark
purpose
1
Vss
ground
2
Vdd
5V
3
Vo
contrast
4
Rs
mode
5
RW
read/write
6
En
isDataReady
7
D0
data line 0
8
D1
data line 1
9
D2
data line 2
10
D3
data line 3
11
D4
data line 4
12
D5
data line 5
13
D6
data line 6
14
D7
data line 7
15
A
anode
16
K
cathode
To play within LCD I assembled a scheme that can work in diff modes, demonstrating different possibilities: text, moving line, custom symbols, animation.
This component well knows by everyone - u use it with your tv or another remote device. It is widely used as one of the easiest ways to get wireless technology.
Before testing this component, it’s good to know what is infrared and how this component work.
If we go to wiki, we can find the next explanation: “Infrared (IR), sometimes called infrared light, is electromagnetic radiation (EMR) with wavelengths longer than those of visible light. It is therefore invisible to the human eye.”.
To use infrared light we need at least an IR receiver and remote. Next point - we should somehow determine signal, thus IR light can be emitted not only by our remote, but also by sun and other sources, so there is a lot of noise around. To make this thing possible, IR signal modulation is used. There are a bit ways to do this, so quite a few protocols for communications exist.
To quickly receive IR signal, I used library available on git, but, if u are interested in details, how a signal is decoded - check this link.
To connect the IR-received to arduino, we just need a few wires - ground, power and a connection for reading results from component. To make things a bit more interested, I added few diodes, so we can control them remotely:
and as usually, assembled scheme:
The code, to make things work:
complete documentation on IRRemote u can find here