# 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 5: Experiment and code

6.4 Experiment and code

If we have already understood the principle of nixietube and the encoding method, the experiment is very simple. Its schematic diagram and circuits can be seen in Figure 6-7 and 6-8. Its corresponding code is shown in Program 6.

Figure 6-7 Schematic diagram of nixie tube

# 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 02  03 void setup() 04 { 05 } 06   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)

where,

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