• [[l.name]]
Topic Platform
Knob Adjustable Light | MindPlus Coding Kit for Arduino Started Tutorial E08 In this section, we introduce a new sensor to simulate a knob-adjustable light to achieve a stepless brightness adjustments. 2. What is an analog signal?

3. What is mapping?

4. Make a knob adjustable light.

### Key Points Analysis

1. Analog and digital signals

Both digital output and digital input are digital signals. They are either 0 or 1, corresponding to low and high levels, respectively.

In the world of Arduino, there is also analog signals besides digital signals.

Arduino’s main control panel controls elements in two methods, digital output and analog output. As for digital output we learnt before, it sends digital signals to the output circuit -- 0 or 1 to control the circuit switch.

Why is an analog signal called so? What exactly does it simulate?

In the process of analog signal transmission, sensors are used to convert various continuous signals in natural world into almost identical electrical signals. For example, the sound of speech is originally vibrations of the vocal cords. Microphone collects them, and converts acoustic signals to electrical signals, whose waveforms are identical. It is only being represented and transmitted in another physical quantity (using electrical signal to simulate the original vibration signals of the sound).

In addition, the pressure sensor also converts the magnitude of the pressure into electrical signals through conversion. Therefore, the analog signal using electrical signals to simulate physical quantities in the natural world.

The following are all analog input sensors: sound sensor, analog angle sensor and light sensor. Any input signals that can be detected are also analog signals. Compared with digital sensors, there is a larger variety in analog sensors, which can obtain more external information. We can regard all analog input sensors as adjustable resistors. The rotation module that will be used here is one of them.

As Ohm's Law defines: V = I x R; voltage = current x resistance. The introduction of analog sensors in the circuit is equivalent to the introduction of adjustable resistors; thus, changes in resistance will also cause voltage changes. 3. What is mapping?

In mathematics, mapping is a functional relationship. It is a “corresponding” relationship between elements of two different sets.  #### Command List ### Hands-On

Hardware connection

Connect the red LED to Digital Pin 10 and the analog angle potentiometer to analog Pin A0. Hardware connection (LED-R-10, analog angle potentiometer-A0)

Please match the colors when plugging

Programming

1. Write the program

As an analog sensor, the analog angle module is actually an adjustable resistor. Knob rotation can trigger the rotation of the internal potentiometer, thereby changing the resistance value. It corresponds to the strength of the analog input signal of the variable.

Arduino can control the brightness of the LED by reading the strength of analog input signals and converting it by mapping. #### 2. Reference program 3. Program’s effect

Rotating the knob changes the brightness of the LED. The greater the rotation angle, the higher the brightness.

4. Program analysis

The program here is relatively simple. We have introduced the concept of mapping, which is a change to the range. But why the original analog signal range is [0, 1023]? Also, what does range [0, 255] mean?

The knob controls the brightness. [0,255] is the brightness range, and [0,1023] is the range of the analog input signal.

Analog signal range

Arduino has 8-bit analog value range (0 - 255) and 10-bit analog value range (0 - 1023).

What is "bit"? Most of mathematics calculations are done in decimal, where one means ten units of the next smaller digit. However in computers, we use binary, where one means two units of the next smaller digit.

The analog output signal is 8 bits, that is, 2 8 = 256; and the initial value is 0, so the range is 255;

The analog input signal is 10 bits, that is, 2 10 = 1024; and the initial value is 0, so the range is 1023.

### Further Exercise

Now that you have learned how to control the brightness with the knob, what else can the knob control? Use your imagination.

FILE Program 3-3 E08.rar 165KB Download 0
1
All Rights
Reserved
[[i.text]] 0
0 [[c.user_name]] [[c.publish_time]]
[[c.parent_comment.count]]
[[r.user.user_name]] [[r.publish_time]]
Affiliate
Related Products
X[[p.num]] [[p.name]]
Related Makelogs
Easy
0 0
Easy
0 0
Easy
1 1
Easy
1 2
Easy
1 1