Monthly Archives: September 2013

Seg 7: Key points and summaries


Figure 7-6 Arduino photon control LED


Figure 7-7 Arduino serial monitor

If we let the outside is much stronger, the value of photoresistor would decrease rapidly. This would let the value of the distribution voltage decreases rapidly, which cannot trigger the Port 8 as a high voltage level on the Arduino board. Therefore, the LED light connected to Port 8 CANNOT be lightened, as seen in Figure 7-8. We can change the strength of the light by using our mobile phone.


Figure 7-8 LED is dark by photoresistor

7.5 Key points and summaries

1) The value of photoresistor would be changed to be small along with the stronger outside light. So the value of voltage is so small that it cannot trigger the Port connected to LED light a high voltage level, which leads LED to be dark.

2) By utilizing the principle of distribution voltage, the photoresistor can control the LED light or dark with Arduino board.

3) Generally speaking, the values of light and dark photoresistor are given out in the product description.

4) Photoresistor is widely applied to the automatic control.

Seg 6: Experiment and code

Next, we will compute the threshold voltage for the photoresistor by Figure 7-3, where, A0 is denoted by the connection to Arduino board, and the positive end is connected to Port 5V on the Arduino board. Evidently, this is a serial circuit, which shows the principle of distribution voltage. V2 is denoted by the voltage of the photoresistor. By the principle of distribution voltage, we have V2=5V*R2/(R1+R2). We can get the voltage value of photoresistor, which is about 3.34V.

However, we can get the voltage value from the analog Port A0 on Arduino board. Its sentence is analogRead(A0). Note that, the output scope of this sentence is a integer within 0~1024 (which can be referred to the syntax of analogRead()). Thus, we should make the analog voltage 3.34V change into the value with 0~1024. We know that 5V is corresponding to 1024, then 3.34V is corresponding to the value 1024*3.34/5=683. This is the threshold voltage, which will be used in the code to control the LED lighten. In addition, the value of threshold voltage is much higher, the photoresistor is more sensitive to the outside light. Its schematic principle can be shown in Figure 7-5.


Figure 7-5 Arduino photon control LED

We can connect the circuit by Figure 7-5, as shown in 7-6. After Program 7 is run, the LED would be lightened by the weak ourside light (or shelter by hand).

01 //Program 7How to photon control light and dark by Arduion
02 int n = 0;    //define n=0 as the read analog port
03 int ledPin8 = 8;   //define ledPin8=8 as the input port
04 int val = 0;       //initialize val
05 void setup() { 
06   Serial.begin(9600);//set baud for the serial port
07   pinMode(ledPin8, OUTPUT);  // set ledPin8 as output mode
08 } 
09  
10 void loop() { 
11   val = analogRead(n);  //read value from sensor
12   
13   Serial.print(val); //open Arduino monitor
14   Serial.println(); //enter and return
15   if(val<=683){//683=23.34V

16     digitalWrite(ledPin8, HIGH); //val less than 683(3.34V), lighten led
17   }
18   else{
19     digitalWrite(ledPin8, LOW);
20   }
21 }


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 4: Characteristics of photoresistor

  1. Main parameters of photoresistor

    1) Light resistor (kΩ): means the value of resistor by light irradiation.

    2) Dark resistor (MΩ): means the value of resistor under no light irradiation.

    3) High voltage (V): means the allowable highest voltage for the photosensitive resistor under the rated power.

    4) light current: means the current when the photosensitive resistor by the light irradiation under the provisions of the applied voltage.

    5) dark current (mA): means the current when the photosensitive resistor by no light irradiation under the provisions of the applied voltage.

    6) time constant (s): means the time when the current of photoresistor is 63% of the stable current from the start by the light irradiation.

    7) resistor temperature coefficient: means the change of the resistor value when the environment temperature changes 1 c.

    8) Sensitivity: means the change for the photosensitive resistor when no light and light irradiation.

  2. Application for photoresistor

It is widely used in various automatic control circuit (such as automatic lighting control circuit, automatic alarm circuit, etc.), household electrical appliances (such as TV automatically adjust the brightness, the automatic exposure control of the camera, etc.) and all kinds of measuring instruments.

Seg 3: Characteristics of photoresistor

  1. structure of photoresistor

As for the photoresistor, there are main three structures: snake, comb, and carved structures. Usually, it is compose of photosensitive layer, the glass substrate moistureproof film (or branch) and the electrode.



  1. photo consitution (b) snake



(c) carved structure (d) comb

Figure 7-2 constitution and structure of photoresistor

  1. classification

1by the materials: polycrystalline and single crystal silicon photosensitive resistor, CdS, PbS, PbSe, InSb, photoresistor, and so on.

2by the property of photon spectrum:

● Visible light resistor: which is mainly used in all kinds of photoelectronic automatic control system, electronic camera, photon alarm, and so on.

●Ultraviolet light photoresistor: which is mainly Uv detection instrument.

●Infrared photosensitive resistor: which is mainly used in astronomy, military and other fields related to automatic control system.

  1. characteristics of photoresistor

Photosensitive resistor is a special resistor by the use of the photoconductive semiconductor effect, which is sensitive to light. Its resistance value can be changed as the outside light intensity (shade). If in the light irradiation, it would show a high impedance state; While a light irradiation, the resistance decreases rapidly.

Seg 2: Characteristics of photoresistor

7.3 Characteristics of photoresistor

Before doing the experiment, we should understand the properties and principle of photoresistor. So, in the section, we will focus on the introduction to the characteristics of photoresistor.

  1. photoconductive effect

It is also called as photoelectronic effect, or photosensitive effect, and introduced by the Semiconductor materials conductivity change. That is, when the material absorbs the photon energy, which can generate the intrinsic absorption or impurity absorption. This would cause the change of the carrier concentration, and thus make the material conductivity change. This phenomenon is called the photoelectronic effect.

  1. express of photo resistor

The photoresistor is a resistor, whose value would be changed by the change of the strength of the incident light by use of the photoelectronic effect. Thus, it is also named as the photoconductive detector. More stronger of the incident light, the resistor value decreases; while weaker, the value of resistor increases. In addition, there exists another contrary change resistor, as shown in Figure 7-1. Generally speaking, its letter label can be written as “RL”, “RG”, or “R”.



  1. photoresistor (b) express of photoresistor

Figure 7-1 photoresistor and its express

  1. photoconductive material

Some materials have the photoconductive effect, such as Si, Ge, CdS, CdSe, PbS, and so on. The products generated from these materials can change the electrical conductivity along with the strength of the incident light.

Seg 1: How to use Arduino make a controllable LED light?

7.1 Problem: How to use Arduino make a controllable LED light?

In this experiment, we will use an Arduino board to make a controllable LED light, which let LED light bright and/or dark by the strength of light. This experiment is very usable. For example, when night is coming, we should let the street lamp light, and the lamp should be dark in the daytime for the energy saving. So, with respect to this experiment, we can make a light controllable lamp in our home. Similarly, we can also make voice controllable LED light.

7.2 The required materials

The required materials are also very simple in this example. On the basis of experiment, we just use photoresistor to replace the nixie tube, which are shown in Table 7-1.

The required materials

Number

Name Quality Function Note

1

Arduino software 1 suit Provide ide New ver 1.05

2

Arduino UNO board 1 Control board Many

3

USB data line 1 Connect board distribution

4

Dupont line 2 Connect elements optional

5

Photoresistor 1 control optional

7

Bread board Connection optional

 

Seg 6: Experiment and code


Figure 6-8 Experimental circuits

byte seven_seg_digits[10][8] = { // set the code array by the number and pins

{ 1,1,1,1,1,1,1,0 }, // = 0

{ 0,0,1,1,1,0,0,0 }, // = 1

{ 1,1,0,1,1,1,0,1 }, // = 2

{ 0,1,1,1,1,1,0,1 }, // = 3

{ 0,0,1,1,1,0,1,1 }, // = 4

{ 0,1,1,1,0,1,1,1 }, // = 5

{ 1,1,1,1,0,1,1,1 }, // = 6

{ 0,0,1,1,1,1,0,0 }, // = 7

{ 1,1,1,1,1,1,1,1 }, // = 8

{ 0,1,1,1,1,1,1,1 } // = 9

};

void setup() { //set 4-11 as OUTPUT

pinMode(4, OUTPUT);

pinMode(5, OUTPUT);

pinMode(6, OUTPUT);

pinMode(7, OUTPUT);

pinMode(8, OUTPUT);

pinMode(9, OUTPUT);

pinMode(10, OUTPUT);

pinMode(11, OUTPUT);

}

void sevenSegWrite(byte digit) { //set the digital array by the order of the ports 4-11 on arduino

byte pin = 4;

for (byte segCount = 0; segCount < 8; ++segCount) {

digitalWrite(pin, seven_seg_digits[digit][segCount]);

++pin;

}

}

void loop() { //display the digital number by reverse order

for (byte count = 10; count > 0; –count) {

delay(1000);

sevenSegWrite(count – 1);

}

delay(2000);

}

6-5 Key points and summaries

  1. Nixie tube can be divided into the common anode and cathode. The judgments may have Arduino used directly and multimeter.
  2. We should know the order of the pins by digital number and letter. This can help us to get the code array for each digital number.
  3. When encoding, we should connect the pins of nixie tube and the ports on the Arduino. It will be difficult to connect each other with error.

Seg 4: Order of the pins for the nixie tube and coding

  1. Order of the pins of the nixie tube

Similarly, why do we know the order the pin? If we do not know the order of the pins, we do not know how to connect to the pins of nixietube. For example, if we want to display the digital number 5, how can we connect the dupon lines from the pins of nixie tube to the ports on the Arduino? To connect to the Arduino board rightly, we must know the connect rules.

  1. re-know the nixie tube

We firstly know the pins of nixie tube from the followings in Figure 6-6.


Figure 6-6 Pins connection of nixie tube

  1. As shown on the left subfigure of Figure 6-6, the digital number is labeled from the lower left by the counterclockwise, and the number of point is 5. All of the number is 1~10.
  2. The letter label is marked from up to down by the clockwise. It is a~h, respectively, where the number of point is “h” as the last location.
  3. Digital number 3 and 8 is the common port, which is the common anode or cathode. Figure 6-6 is the common cathode nixie tube; that is, all of the negative pins are connected a common port 3 or 8.
    1. Coding of nixie tube

What is coding? To make the nixie tube display the designed digital number, we should let the LED to be conduction. For example, we want to display number 5 in Figure 6-6, how? Firstly, the polarity is must be right. In such experiment, the nixie tube is the common cathode. Thus, the common cathode should be connected to the GND port on the Arduino. Other pins must be corresponding to the ports on the Arduino to display the right digital number. This is coding. For example, in the letter view, if let the pins of a,c,d,f,g set as a high voltage level (or 1), and other pins is set as low level, (or 0), then, the corresponding segments would be light and digital number 5 can be displayed on the nixie tube. Since the decimal point “h” would not affect the display of digital number, it can be conducted or not. In this experiment, the decimal point is conducted. From the digital view, pins 2,4,5,7,9,10 are conducted, and the other remaining ones are not. Therefore, if we use binary code to express this segment, it can be coded as {0,1,1,1,0,1,1,1}. That is, there are two segments dark among of the eight segments in the nixie tube. Then, digital number “5″ can be displayed correctly. By this coding method, we can get other digital number coding, as shown in Table 6-2.

Table 6-2 Digital number coding scheme for the common cathode nixie tube

Arduino ports

Nixietube pins

0

1

2

3

4

5

6

7

8

9

4

1(e)

1

0

1

0

0

0

1

0

1

0

5

2(d)

1

0

1

1

0

1

1

0

1

1

6

4(c)

1

1

0

1

1

1

1

1

1

1

7

5(Dp)

1

1

1

1

1

1

1

1

1

1

8

6(b)

1

1

1

1

1

0

0

1

1

1

9

7(a)

1

0

1

1

0

1

1

1

1

1

10

9(f)

1

0

0

0

1

1

1

0

1

1

11

10(g)

0

0

1

1

1

1

1

0

1

1

Note that, to avoid the error of connection to Arduino, or convenience, we had better encode the digital number by one-defined rule. For example, in this experiment, let the digital ports on Arduino board correspond to the pins of nixietube for small to big (1~10). Certainly, there are many encoding schemes by following different ones’ habits. But the effect of display and the code is the same.