Tag Archives: voltage

Seg 5: Experiment and principle

7.4 Experiment and principle

Only when we understand the characteristics, we may feel that the principle of this experiment is very simple, which is simply interpreted as the distribution voltage between the photoresistor and the serial resistor. If the distribution of voltage for the photoresistor is less than a threshold voltage, it can trigger a high voltage level for the port 8 on the Arduino board in such experiment, which can light LED; or port 8 would be at a low voltage level, and thus the LED doesn’t be lightened. But, why should the voltage of photoresistor lower a threshold voltage, the LED would light. Let us analyze its principle. Assume that a photoresistor control lamp would be installed in our home. When the outside light is strong, we hope the lamp doesn’t be lightened for the energy saving. At the same time, the value of photoresistor is changed to be small. As shown in Figure 7-3, the photoresistor and a usual resistor are connected serially each other and powered by the energy source 5V provided by Arduino board. By the circuit principle, if the value of photoresistor is more smaller, the value of distribution voltage is more smaller. Therefore, we can draw a conclusion. If the outside light is more stronger, the value of photoresistor is more smaller, and it thus leads to a fact that the value of the distribution voltage is small. So, if the distribution voltage for the photoresistor is less than a threshold voltage, it cannot trigger the Port 8 a high level, which results in the LED dark.

However, we have another problem: how can we get the threshold voltage for the photoresistor? This is a key problem. As shown in Figure 7-3, R1 is the serial resistor, and R2 is the photoresistor (temporarily replaced of the photoresistor in this figure), where the value 20Ω is named as light resistor, which can measured by utilizing multimeter shown in Figure 7-4. The real measured value is 17.49Ω by multimeter, but for computation conveniently, it is 20Ω. Additionally, this value and dark resistor value are given out generally in the description of product.

Figure 7-3 Distribution voltage principle for the photoresistor

Figure 7-4 The measured light resistor value by using multimeter for the photoresistor

Seg 2: Experiment, principle, and code

5.4 Experimental principle

The principle is simple in this experiment, which is summarized as follows. The buzzer can make a sound, since the current on the buzzer is powered on the electromagnetic coil, which can make coil generate magnetic field. Then it can drive vibrating diaphragm to generate a sound. This is the reason why the buzzer must need the current. Its schematic principle is drawn in Figure 5-3. In our such experiment, port 9 on the Arduino board can provide a voltage for the passive buzzer. Then it can generate a sound. It is worth noting that, the rated voltage for the buzzer is 5V, while the Arduino’s max voltage is 5V as well. Therefore, the circuit cannot connect serially a resistor. If connected, then the buzzer doesn’t work.

5.5 Experiment and code

In fact, the circuit connection of such experiment is very simple, which is seen in Figure 5-3. After run Program 5, Arduino can generate alarm sound.

Figure 5-3 Experimental circuit

01 // Program 5: how to use Arduino and buzzer generate alarm sound
03 void setup()
04 {
05 }
07 void loop()
08 {
09 for(int i=200;i<=800;i++)   // frequency from 200Hz to 800Hz
10 {
11   pinMode(4,OUTPUT);
12   tone(4,i);       //output frequency at port 4, i.e., generate a sound
13  delay(5);       //generate a sound for 5ms 
14 }
15 delay(4000);           //the highest frequency lasts for 4ms
16 for(int i=800;i>=200;i)
17 {
18   pinMode(4,OUTPUT);
19   tone(4,i);
20  delay(10);
21 }
22 }

Here, a new Arduino function “tone” is introducted. Its syntax is:

tone(pin, frequency)

tone(pin, frequency, duration)


pinwhich is defined on the Arduino board

frequency: the voice frequency, unit is Hz, unsigned int

durationvoice lasting time, unit is ms (optional), unsigned long

5.6 Key points and summaries

1) The buzzer can be divided into active and passive. The active one can make a sound by directly connecting power, while the passive one can generate a sound only for the changing frequency. Therefore, the buzzer can make a sound on the Arduino board by PWM technique. But, it cannot connect serially a resistor.

2) The principle of buzzer is that, when the current passes through the electromagnetic coil, it will generate a magnetic field, which can drive the vibrating diaphragm make a sound periodically.

Seg 2: Relevant Concepts

4.3 Experimental principle

Before presenting the experiment principle, some relevant concepts should be given out firstly.

Digital signal: its means that its amplitude is discrete, and limited into a range, like binary code used widely in computer science. The digital signal has a strong anti-interference ability, and can be easily processed by digital signal processing. Nowadays, there are many digital signals, such as mobile signal, information handling by computer, and so on.

Analog signal: its ware changes continuously. Theoretically, we can get any of the value from the analog signal. Since it is interfered easily by the other signals, it is difficult to handling. Thus, generally, the analog signal should firstly be transformed into the digital signal for the convenient signal processing. The difference could be shown in Figure 4-1.

Figure 4-1 Difference of digital and analog signals

PWM is the abbreviation of Pulse Width Modulation. It means that we can equivalently get the required signal wave on the basis of a series pulse width, as shown in Figure 4-2. We can achieve a sine signal wave by a series of pulse signal by the different width. In fact, this principle can be illustrated by the equivalent area from mathematical integral. For example, the area of the first pulse is equivalent to the area surrounded by sine signal wave. So, we can change the duty cycle to get the voltage signal wave. Please image it. If we want to get a direct current voltage wave, the width of each pulse should be equal. In addition, PWM technique has been widely applied to the motor speed control, valve control, and so on. For example, PWM has been used to electronic cars.

Figure 4-2 Sine wave by PWM

Seg 1: How to use Arduino controller and button to control the blink of LED

3.1 Problem description: How to use Arduino controller and button to control the blink of LED

The previous two examples are relatively simple. When the corresponding codes are burn into the Arduino board, then the LED could blink. But it cannot interact with people. So, in our such experiment, by adding a new material, button, to control the blink of LED.

3.2 The required material

Table 3-1 the required material


Name Qua Function Note


Arduino software 1 IDE Version 1.05


Arduino UNO board 1 board


USB line 1 burn


Dupont lines many Connection elements




Resistor (10, 200Ω) 2 Current limited


Breadboard board 1 connection


button 1 onoff

Before doing this experiment, we firstly introduce the relevant properties of botton.


Button is an usual device in the design embedded system. By button, some instructions and data can be utilized to control the on/off states, which can control the run states of some devices. For example, in this experiment, by button, the high/low level is generated to control the blink of LED. But, there are many kinds of switches, such as a single switch in kitchen, double switches in bedroom, voice control switch in corridor, and so on. In our such experiment, we mainly use small/or miniature switches, as shown in Figure 3-1.

Figure 3-1 Miniature buttons

And the size of the miniature switch in this experiment is about 6*6*5mm and has four legs, which is shown in Figure 3-2.

Figure 3-2 Miniature button in this experiment

Note that, the two logs divided by a deep ditch is the same side. Its principle is also given out in Figure 3-2. If the button is pushed down, the four logs 1,2,3,4 would connected each other. Then this can trigger a high level to light the LED. But if you relax the button, 1,2,3,4 would be off

Figure 3-3 Schematics of button