Seg 2: Schematics and Experiments

3.3 Schematics for experiment

When button is pressed down, a high voltage level can be obtained. Then it will trigger Arduino to control the blink of LED. Certainly, we can let the LED blink when the button is pressed down. Its schematic is shown in Figure 3-4, which can be viewed as extension from the first experiment by adding a button.

Figure 3-4 Experiment principle diagram

And its real circuit is shown in Figure 3-5.

Figure 3-5 Circuit block

After the circuit is prepared by Figure 3-5, Program 3 can be run, which is also presented as follows.

01 //Program 3: How to control the blink of LED by Arduino and button
03 int led8=8;// set pin 8 as the digital port for LED on the Arduino board
04 void setup()
05 {
06  pinMode(led8,OUTPUT);// set digital port 8 as OUTPUT
07 }
08 void loop()
09 {
10    int i;// define i as the received voltage
11    i=analogRead(0);//read analog port 0 to port i
12    if(i>512)// set the voltage threshold as i>512(i.e., 2.5V)
13      {digitalWrite(led8,HIGH);// then set port 8 as a high level, which can make led blink
14      delay(2000);}//make LED blink for 2s
15    else
16      digitalWrite(led8,LOW);// if i<512, let port 8 to be a low level, which make led extinguish 
18 }

OK, at this time, when you push down the button, LED can be lighted. But, unfortunately, if you unpress the button, an expected result happens. That is, the LED is still lighting, even if the button loosed. Furthermore, if you hold an end of dupont line by your hand, the LED is still light, as shown in Figure 3-6. But why?

Figure 3-6 Holding an end of dupont, LED is still light

It turns out that, there exists interference around one’s body or environment to some extent. Therefore, even if the button doesn’t be pressed, LED can light. Then, the interface will affect our such experiment by a voltage level, which can trigger the Arduino board to control the state of LED. Certainly, the interface would be different from difference of body and environment. So, when the button is pressed down, because of the flexibility of button, the button cannot trigger the Arduino board with a high voltage level quickly and steadily. There exist some jitters for some time. The length of time is different and determined by the mechanical features. In general, the time is 5~10ms. This is a very important parameter to design a control system. The phenomenon is shown in Figure 3-7. Before or after pressing the button, there exist some jitters. So, we must delete these jitters to avoid the error decision.

Figure 3-7 Jitters appearance

To avoid doing an error choice, we must remove the appearance. There are many ways to remove jitters from hardware and software. It is worth noting that, even if the voltage threshold is set as a value bigger than 512 (512 is a pwm value. In the next sections, we will introduce its principle) in Program 3, the jitter appears as well. What’s more, during the process of our experiment, when i=1000, the LED would light in case the button doesn’t push down. So, we must remove the jitter according to the principle.

Figure 3-8 schematic after adding a bias resistor

2 thoughts on “Seg 2: Schematics and Experiments

Leave a Reply to chaussures ugg Cancel reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>