Chapterبەش 5 · Lectureوانە 5.3
Reading Analog Signals: the ADC and analogRead()خوێندنەوەی سیگناڵەکانی ئەنالۆگ: ADC و analogRead()
How a board reads a smooth voltage: analog and digital outputs, the ADC inside the microcontroller, n bits = 2ⁿ levels, the step size and the formulas between readings and volts, analogRead() on the UNO R3, UNO R4 and MKR WAN 1310 with analogReadResolution(), the reference voltage and analogReference(), a TMP36 worked example, floating pins and averaging.
بۆرد چۆن نەرم دەخوێنێتەوە: و ، ADCـی ناو ، = ئاست، قەبارەی هەنگاو و نێوان خوێندنەوە و ، analogRead() لەسەر UNO R3، UNO R4 و MKR WAN 1310 بە analogReadResolution()، و analogReference()، نموونەیەکی هەنگاوبەهەنگاوی TMP36، و تێکڕا.
What you will learnچی فێر دەبیت
- Explain what an ADC does and why an analog sensor needs one.
- Work out the number of levels and the step size for 8, 10, 12 and 14 bits.
- Convert an analogRead() value to volts, and volts to the expected value.
- Use analogRead() and analogReadResolution() on the UNO R3, UNO R4 and MKR WAN 1310 with the right reference voltage.
- Explain why an unconnected analog pin reads noise, and smooth readings by averaging.
- ڕوونی بکەیتەوە ADC چی دەکات و بۆچی پێویستی پێیەتی.
- ژمارەی ئاستەکان و قەبارەی هەنگاو بۆ 8، 10، 12 و 14 بدۆزیتەوە.
- نرخێکی analogRead() بگۆڕیت بۆ و بۆ نرخە چاوەڕوانکراوەکە.
- analogRead() و analogReadResolution() لەسەر UNO R3، UNO R4 و MKR WAN 1310 بە دروست بەکار بهێنیت.
- ڕوونی بکەیتەوە بۆچی نەبەستراو دەخوێنێتەوە و خوێندنەوەکان بە تێکڕا ئارام بکەیتەوە.
From a smooth voltage to a numberلە ڤۆڵتیەیەکی نەرمەوە بۆ ژمارەیەک
Turn the knob of a potentiometer, and the voltage on its middle leg glides smoothly from 0 V to 5 V. A TMP36 gives 0.75 V at 25 °C and 0.76 V at 26 °C. digitalRead() cannot tell you any of that: it only answers HIGH or LOW. To read how much, the microcontroller uses a converter built into it, the ADC, through its analog input pins.
دەسکی (potentiometer) بسووڕێنە و قاچە ناوەڕاستەکەی بە نەرمی لە 0 Vـەوە بۆ 5 V دەڕوات. TMP36 لە 25 °Cـدا 0.75 V و لە 26 °Cـدا 0.76 V دەدات. digitalRead() ناتوانێت هیچ کام لەمانەت پێ بڵێت: تەنیا HIGH یان LOW وەڵام دەداتەوە. بۆ خوێندنەوەی چەندە، گۆڕەرێکی ناوخۆیی بەکار دەهێنێت، (ADC)، لە ڕێی .
In this lesson the ADC turns volts into numbers: how many levels it has, how big one step is, what analogRead() returns on each board, why the reference voltage matters, and why a pin with nothing on it gives random numbers. How analog and digital signals differ in general is in Analog and Digital Signals; how sound becomes samples is in How sound becomes numbers.
لەم وانەیەدا ADC دەکاتە ژمارە: چەند ئاستی هەیە، یەک هەنگاو چەند گەورەیە، analogRead() لەسەر هەر بۆردێک چی دەگەڕێنێتەوە، بۆچی گرنگە و بۆچی پینێک کە هیچی پێوە نییە دەدات. جیاوازیی گشتیی و لە سیگناڵەکانی ئەنالۆگ و دیجیتاڵـدایە؛ چۆنیەتیی بوونی دەنگ بە نموونە لە دەنگ چۆن دەبێتە ژمارەـدایە.
Two kinds of sensor outputدوو جۆری دەرخستەی هەستەوەر
Classified by their output signal, sensors are analog or digital (Analog or digital output?). An analog sensor gives an output that varies continuously with the quantity — for example a voltage anywhere from 0 to 5 V — so it needs analog-to-digital (A/D) conversion before a program can use it. A digital sensor's output moves in discrete steps, 0s and 1s, the form digital communication uses, so no A/D conversion is needed on the board.
بەپێی ، یان (دەرخستەی ئەنالۆگ یان دیجیتاڵ؟). دەدات کە بە بەردەوامی لەگەڵ بڕەکەدا دەگۆڕێت — بۆ نموونە لە هەر شوێنێکی نێوان 0 و 5 Vـدا — بۆیە پێش ئەوەی بەکاری بهێنێت پێویستی بە گۆڕینی بۆ (A/D) هەیە. بە هەنگاوی جیا دەجووڵێت، 0 و 1، ئەو شێوەیەی پەیوەندیی بەکاری دەهێنێت، بۆیە لەسەر بۆردەکە پێویستی بە گۆڕینی A/D نییە.
Both kinds need power. An outside source — wind speed, sunlight, light intensity — acts on the sensor; an excitation supply and ground feed it; and it gives out a voltage or a current: a smooth signal from an analog sensor, a square wave from a digital one.
هەردوو جۆرەکە پێویستیان بە وزەیە. سەرچاوەیەکی دەرەکی — خێرایی با، تیشکی خۆر، توندیی ڕووناکی — کار لە دەکات؛ ورووژاندن و وزەی دەدەنێ؛ و یان دەداتە دەرەوە: نەرم لە ، لە .
The ADC: a tiny measurer inside the chipADC: پێوەرێکی بچووک لە ناو چیپەکەدا
An analog signal can take any number of values; a digital signal has only two, HIGH and LOW. To measure an analog voltage, the microcontroller (MCU) — the tiny computer chip on the board that runs your sketch and controls sensors and circuits — has a built-in analog-to-digital converter (ADC): a tiny machine that takes a real-world voltage and turns it into a number that the code can understand.
دەتوانێت هەر ژمارەیەک نرخ وەربگرێت؛ تەنیا دوو نرخی هەیە، HIGH و LOW. بۆ پێوانی ، (MCU) — ئەو کۆمپیوتەرە بچووکەی سەر بۆردەکە کە جێبەجێ دەکات و و کۆنترۆڵ دەکات — (ADC) ناوخۆیی هەیە: ئامێرێکی بچووک کە جیهانی ڕاستەقینە وەردەگرێت و دەیکاتە ژمارەیەک کە کۆدەکە تێی بگات.
On an UNO the six analog pins A0–A5 share one ADC: a selector inside the chip, a multiplexer, connects one pin at a time. The ADC compares the pin's voltage with a reference voltage (5 V on an UNO) and answers one question: what fraction of the reference is this? — as a whole number.
لەسەر UNO شەش A0 تا A5 یەک ADC بەکار دەهێنن: هەڵبژێرێک لە ناو ، واتە ، لە هەر جارێکدا یەک پین دەبەستێتەوە. ADC پینەکە لەگەڵ (5 V لەسەر UNO) بەراورد دەکات و وەڵامی یەک پرسیار دەداتەوە: ئەمە چ بەشێکی ؟ — وەک .
n bits, 2ⁿ levels بیت، ئاست
An ADC with n bits sorts its input into levels, numbered from 0 to (How many patterns do N bits give?). The largest number is always one less than the number of levels, because counting starts at 0.
ADCـێک بە دابەش دەکات بەسەر ئاستـدا کە لە 0ـەوە تا ژمارە دەکرێن ( بیت چەند شێوە دەدات؟). گەورەترین ژمارە هەمیشە یەکێک کەمترە لە ژمارەی ئاستەکان، چونکە ژماردن لە 0ـەوە دەست پێ دەکات.
| Bits | Levelsئاستەکان | Valuesنرخەکان | Whereلە کوێ |
|---|---|---|---|
| 3 | 8 | 0–7 | the staircase picture belowوێنەی پەیژەکەی خوارەوە |
| 8 | 256 | 0–255 | MKR boards can be set to 8 bitsبۆردەکانی MKR دەتوانن لەسەر 8 دابنرێن |
| 10 | 1,024 | 0–1023 | UNO R3, Nano, Mega; the default everywhereUNO R3، Nano، Mega؛ بنەڕەت لە هەموو شوێنێک |
| 12 | 4,096 | 0–4095 | MKR WAN 1310, Nano 33 IoTMKR WAN 1310، Nano 33 IoT |
| 14 | 16,384 | 0–16383 | UNO R4 Minima and WiFiUNO R4 Minima و WiFi |
So a 12-bit ADC gives 0 to 4095, not 0 to 4096: 4096 is the number of levels, not the top value. In the same way an 8-bit ADC gives 0 to 255.
بۆیە ADCـێکی 12 لە 0 تا 4095 دەدات، نەک 0 تا 4096: 4096 ژمارەی ئاستەکانە، نەک بەرزترین نرخ. بە هەمان شێوە ADCـێکی 8 لە 0 تا 255 دەدات.
n bits, 2ⁿ levels بیت، ئاست
The staircase: 3 bits from 0 to 5 Vپەیژەکە: 3 بیت لە 0 تا 5 V
Picture a 3-bit ADC with a 5 V reference. Its 8 levels split 0–5 V into 8 steps of 5 ÷ 8 = 0.625 V. As the input rises smoothly, the output climbs a staircase: 0 to 0.625 V gives 000, 0.625 to 1.25 V gives 001, and so on, up to 111 for 4.375 V and above.
ADCـێکی 3 بە 5 V وێنا بکە. 8 ئاستەکەی 0 تا 5 V دەکەنە 8 هەنگاوی 5 ÷ 8 = 0.625 V. کاتێک بە نەرمی بەرز دەبێتەوە، بە پەیژەیەکدا دەچێتە سەرەوە: 0 تا 0.625 V دەبێتە 000، 0.625 تا 1.25 V دەبێتە 001 و بەم شێوەیە، تا 111 بۆ 4.375 V و سەرووتر.
Every voltage inside one step gives the same code: 2.0 V and 2.4 V both give 011, which is 3. That lost detail is the price of turning a smooth voltage into a number. More bits make the steps smaller, never zero.
هەموو لە ناو یەک هەنگاودا هەمان کۆد دەدات: 2.0 V و 2.4 V هەردووکیان 011 دەدەن، کە 3ـە. ئەو وردەکارییە لەدەستچووە نرخی گۆڕینی نەرمە بۆ ژمارە. زیاتر هەنگاوەکان بچووکتر دەکەن، بەڵام هەرگیز سفریان ناکەن.
n bits, 2ⁿ levels بیت، ئاست
Watch analogRead() follow a knobسەیری analogRead() بکە کە بەدوای دەسکێکدا دەڕوات
On a real UNO the ADC has 10 bits, so the staircase has 1024 steps — too small to see — and the animation shows the number instead. A potentiometer on A0 is turned from 0 V to 5 V while a sketch prints analogRead(A0). The number follows the voltage in proportion: about half of 5 V gives about half of 1023.
لەسەر UNOـی ڕاستەقینە ADC 10 هەیە، بۆیە پەیژەکە 1024 هەنگاوی هەیە — زۆر بچووکن بۆ بینین — بۆیە لەبری ئەوە ژمارەکە پیشان دەدات. لەسەر A0 لە 0 Vـەوە بۆ 5 V دەسووڕێنرێت لە کاتێکدا analogRead(A0) چاپ دەکات. ژمارەکە بە ڕێژە بەدوای دەڕوات: نزیکەی نیوەی 5 V نزیکەی نیوەی 1023 دەدات.


How big is one step?یەک هەنگاو چەند گەورەیە؟
One step — also called 1 LSB, the value of the least significant bit — is the reference voltage divided by the number of levels:
یەک هەنگاو — کە پێی دەوترێت 1 LSBـیش، واتە نرخی کەمگرنگترین بیت — دابەش بە ژمارەی ئاستەکان:
The Arduino reference rounds the UNO's step the same way: 5 volts / 1024 units, about 4.9 mV per unit. This step is the ADC's resolution: a change smaller than one step may not change the reading at all (Resolution: the smallest step you can see).
سەرچاوەی Arduino هەنگاوی UNO بە هەمان شێوە نزیک دەکاتەوە: 5 / 1024 یەکە، نزیکەی 4.9 mV بۆ هەر یەکەیەک. ئەم هەنگاوە ADCـە: گۆڕانێکی بچووکتر لە یەک هەنگاو لەوانەیە هەرگیز خوێندنەوەکە نەگۆڕێت (توانای جیاکردنەوە: بچووکترین هەنگاو کە دەبینرێت).
How big is one step?یەک هەنگاو چەند گەورەیە؟
What one step means for a thermometerیەک هەنگاو بۆ گەرماپێوێک واتای چییە؟
Imagine a temperature sensor whose output covers 0–50 °C across the ADC's whole range. With 8 bits, the 256 levels split 50 °C into steps of about 0.2 °C; with 10 bits, about 0.05 °C; with 12 bits, about 0.012 °C — the difference between seeing 37.1 °C and 37.12 °C.
وێنا بکە کە 0 تا 50 °C بەسەر هەموو ئاستەکانی ADCـدا دابەش دەکات. بە 8 ، 256 ئاستەکە 50 °C دەکەنە هەنگاوی نزیکەی 0.2 °C؛ بە 10 نزیکەی 0.05 °C؛ بە 12 نزیکەی 0.012 °C — جیاوازیی نێوان بینینی 37.1 °C و 37.12 °C.
Even 8 bits is far finer than "cold, medium, hot", which needs only 2 bits (4 levels). And the ADC is often not the real limit: a sensor that is only accurate to ±2 °C gains nothing real from 0.012 °C steps (Many digits do not make a good sensor).
تەنانەت 8 زۆر وردترە لە «سارد، مامناوەند، گەرم» کە تەنیا 2 (4 ئاست) پێویستە. هەروەها زۆرجار ADC سنووری ڕاستەقینە نییە: کە تەنیا ±2 °Cـە هیچ سوودێکی ڕاستەقینە لە هەنگاوی 0.012 °C وەرناگرێت (ژمارەی زۆری دوای فاریزە هەستەوەرێکی باش دروست ناکات).
From reading to volts, and backلە خوێندنەوەوە بۆ ڤۆڵت و بە پێچەوانەوە
The ADC counts how many whole steps fit under the input voltage, so a reading is the voltage divided by one step, rounded down; going back, multiply the reading by the step:
ADC دەژمێرێت چەند هەنگاوی تەواو لە ژێر نێوخستەدا جێ دەبنەوە، بۆیە خوێندنەوە دابەش بە یەک هەنگاو، بەرەو خوار نزیککراوە؛ بۆ گەڕانەوە، خوێندنەوەکە لێکبدە لە هەنگاوەکە:
Worked example on an UNO R3. The true voltage lies somewhere from 2.368 V to 2.373 V: inside one step.
نموونەیەکی هەنگاوبەهەنگاو لەسەر UNO R3. ڕاستەقینە لە شوێنێکی نێوان 2.368 V و 2.373 Vـدایە: لە ناو یەک هەنگاودا.
A sensor that changes its resistance, such as an LDR, gives no voltage by itself: a voltage divider turns it into a voltage that these formulas can use (The voltage divider).
کە دەگۆڕێت، وەک ، خۆی هیچ نادات: دەیکات بە کە ئەم بەکاری بهێنن (دابەشکەری ڤۆڵتیە).
analogRead() on an UNOanalogRead() لەسەر UNO
analogRead(pin) reads the voltage on an analog input pin such as A0 and gives you a number that represents it — not the voltage itself. On a 10-bit board the number goes from 0 to 1023, relative to the reference voltage. By default the reference is the board's operating voltage: 5 V on an UNO, 3.3 V on MKR boards. The pin needs no pinMode() for this.
analogRead(pin) وەک A0 دەخوێنێتەوە و ژمارەیەکت دەداتێ کە نوێنەرایەتیی دەکات — نەک خودی . لەسەر بۆردێکی 10 ژمارەکە لە 0 تا 1023ـە، بەپێی . بە شێوەی بنەڕەت کارکردنی بۆردەکەیە: 5 V لەسەر UNO و 3.3 V لەسەر بۆردەکانی MKR. پینەکە بۆ ئەمە پێویستی بە pinMode() نییە.
Lab: connect a 10 kΩ potentiometer — its outer legs to 5V and GND, its middle leg (the wiper) to A0 — and print the reading and the voltage twice a second:
تاقیگە: 10 kΩ ببەستە — قاچە دەرەکییەکانی بە 5V و GND، قاچە ناوەڕاستەکەی بە A0 — و خوێندنەوەکە و چرکەی دوو جار چاپ بکە:
// Read a voltage on A0 and print it (Arduino UNO R3: 10-bit ADC, 5 V reference)
const int sensorPin = A0;
void setup() {
Serial.begin(9600);
}
void loop() {
int reading = analogRead(sensorPin); // 0 to 1023
float volts = reading * 5.0 / 1024.0; // one step = 5 V / 1024
Serial.print("reading = ");
Serial.print(reading);
Serial.print(" volts = ");
Serial.println(volts);
delay(500);
}reading = 0 volts = 0.00 reading = 225 volts = 1.10 reading = 491 volts = 2.40 reading = 757 volts = 3.70 reading = 1023 volts = 5.00
Run with the CêIT Arduino checker, whose analog scenario turned A0 to 0, 1.10, 2.40, 3.70 and 5.00 V every 500 ms. 1023 × 5 ÷ 1024 = 4.995 V, which prints as 5.00.
بە پشکنەری Arduinoـی CêIT جێبەجێ کراوە، سیناریۆ A0ـی هەر 500 ms جارێک گۆڕی بۆ 0، 1.10، 2.40، 3.70 و 5.00 V. 1023 × 5 ÷ 1024 = 4.995 V، کە وەک 5.00 چاپ دەکرێت.
Explain the codeڕوونکردنەوەی کۆدەکە
- Lineدێڕی 9
analogRead() returns a whole number from 0 to 1023.
analogRead() لە 0 تا 1023 دەگەڕێنێتەوە.
- Lineدێڕی 10
One step is 5 V / 1024; write 5.0 and 1024.0 so the sum is done with decimals.
یەک هەنگاو 5 V / 1024ـە؛ 5.0 و 1024.0 بنووسە بۆ ئەوەی هەژمارەکە بە بکرێت.
- Lineدێڕی 11-14
print() keeps the line open; println() ends it.
print() دێڕەکە کراوە دەهێڵێتەوە؛ println() کۆتایی پێ دەهێنێت.
analogRead() on an UNOanalogRead() لەسەر UNO
How fast? About 10,000 readings a secondچەند خێرا؟ نزیکەی 10,000 خوێندنەوە لە چرکەیەکدا
On ATmega boards — the UNO R3, Nano and Mega — one analogRead() takes about 100 microseconds, so a sketch can read at most about 10,000 times a second: the board's sampling rate. That is plenty for temperature, light or a knob, which change slowly. Sound needs more: a CD stores 44,100 samples a second (How sound becomes numbers).
لەسەر بۆردەکانی ATmega — UNO R3، Nano و Mega — هەر analogRead()ـێک نزیکەی 100 مایکرۆچرکە دەخایەنێت، بۆیە دەتوانێت لە چرکەیەکدا زۆرترین نزیکەی 10,000 جار بخوێنێتەوە: بۆردەکە. ئەمە بۆ پلەی گەرمی، ڕووناکی یان دەسکێک زۆرە، چونکە هێواش دەگۆڕێن. دەنگ پێویستی بە زیاترە: CD لە چرکەیەکدا 44,100 نموونە هەڵدەگرێت (دەنگ چۆن دەبێتە ژمارە).
Many sensors are slower than the ADC anyway: the DHT22 allows one reading every 2 seconds. Reading a sensor faster than it can measure only repeats old values.
زۆر هەر لە ADC هێواشترن: DHT22 هەر 2 چرکە جارێک ڕێگەی خوێندنەوە دەدات. خوێندنەوەی خێراتر لەوەی دەتوانێت بیپێوێت تەنیا نرخی کۆن دووپاتە دەکاتەوە.
analogRead on each boardanalogRead لەسەر هەر بۆردێک
Boards differ in ADC bits, reference voltage and analog pins. The course uses the UNO R3 and the MKR WAN 1310; the UNO R4 is the UNO sold today (Arduino Boards and the Arduino IDE).
بۆردەکان لە ADC، و جیاوازن. کۆرسەکە UNO R3 و MKR WAN 1310 بەکار دەهێنێت؛ UNO R4 ئەو UNOـیە کە ئەمڕۆ دەفرۆشرێت (بۆردەکانی Arduino و Arduino IDE).
| Boardبۆرد | ADC | analogRead() by defaultanalogRead() بە شێوەی بنەڕەت | Reference | Analog pins | One stepیەک هەنگاو |
|---|---|---|---|---|---|
| UNO R3, Nano | 10 bits10 | 0–1023 | 5 V | A0–A5 (Nano A0–A7) | 4.88 mV |
| Mega 2560 | 10 bits10 | 0–1023 | 5 V | 16 (A0–A15)16 پین (A0–A15) | 4.88 mV |
| UNO R4 Minima / WiFi | up to 14 bitsتا 14 | 0–1023 (10 bits)0–1023 (10 ) | 5 V | A0–A5 | 0.31 mV at 14 bits0.31 mV بە 14 |
| MKR WAN 1310 | up to 12 bitsتا 12 | 0–1023 (10 bits)0–1023 (10 ) | 3.3 V | A0–A6 | 0.81 mV at 12 bits0.81 mV بە 12 |
Two surprises. First, the newer boards start at 10 bits too, for compatibility, until you ask for more with analogReadResolution(). Second, on a 3.3 V board the top of the range is 3.3 V: never put 5 V on its pins (5 V boards and 3.3 V boards).
دوو شتی چاوەڕواننەکراو. یەکەم، بۆردە نوێیەکانیش بۆ گونجان لەگەڵ کۆنەکان بە 10 دەست پێ دەکەن، تا بە analogReadResolution() داوای زیاتر دەکەیت. دووەم، لەسەر بۆردێکی 3.3 V بەرزترین کە دەخوێندرێتەوە 3.3 Vـە: هەرگیز 5 V مەخە سەر پینەکانی (بۆردەکانی 5 V و بۆردەکانی 3.3 V).
analogRead on each boardanalogRead لەسەر هەر بۆردێک
More bits: analogReadResolution()بیتەکانی زیاتر: analogReadResolution()
On boards with a bigger ADC, analogReadResolution(bits) sets how many bits analogRead() returns: analogReadResolution(12) gives 0–4095 on the MKR WAN 1310, and analogReadResolution(14) gives 0–16383 on the UNO R4. Ask for more bits than the chip has and the extra bits are filled with zeros; ask for fewer and the lowest bits are dropped. On an UNO R3 the function does not exist, so the sketch will not compile.
لەسەر بۆردەکان کە ADCـی گەورەتریان هەیە، analogReadResolution(bits) دیاری دەکات analogRead() چەند بگەڕێنێتەوە: analogReadResolution(12) لەسەر MKR WAN 1310 0–4095 دەدات و analogReadResolution(14) لەسەر UNO R4 0–16383. داوای زیاتر لەوەی هەیەتی بکە، زیادەکان بە سفر پڕ دەکرێنەوە؛ داوای کەمتر بکە، نزمەکان لا دەبرێن. لەسەر UNO R3 ئەم نییە، بۆیە کۆمپایل نابێت.
// Arduino MKR WAN 1310: read A1 with 10 and with 12 bits (3.3 V reference)
void setup() {
Serial.begin(9600);
while (!Serial) { } // MKR boards: wait until the Serial Monitor is open
}
void loop() {
analogReadResolution(10);
int r10 = analogRead(A1); // 0 to 1023
analogReadResolution(12);
int r12 = analogRead(A1); // 0 to 4095
Serial.print("10-bit: ");
Serial.print(r10);
Serial.print(" 12-bit: ");
Serial.print(r12);
Serial.print(" volts: ");
Serial.println(r12 * 3.3 / 4096.0, 3);
delay(1000);
}10-bit: 310 12-bit: 1241 volts: 1.000 10-bit: 620 12-bit: 2482 volts: 2.000 10-bit: 1023 12-bit: 4095 volts: 3.299
Run with the CêIT Arduino checker (analog scenario on A1). The same voltage gives four times as many steps at 12 bits; the top reading, 4095, is one step below 3.3 V.
بە پشکنەری Arduinoـی CêIT جێبەجێ کراوە (سیناریۆی لەسەر A1). هەمان بە 12 چوار هێندە هەنگاو دەدات؛ بەرزترین خوێندنەوە، 4095، یەک هەنگاو لە خوار 3.3 Vـەوەیە.
Explain the codeڕوونکردنەوەی کۆدەکە
- Lineدێڕی 4
MKR boards talk over native USB: wait until the Serial Monitor is open.
بۆردەکانی MKR بە USBـی ڕاستەوخۆ قسە دەکەن: چاوەڕێ بکە تا دەکرێتەوە.
- Lineدێڕی 8-11
Switch between 10 and 12 bits and read the same pin twice.
لە نێوان 10 و 12 بگۆڕە و هەمان پین دوو جار بخوێنەوە.
- Lineدێڕی 17
At 12 bits one step is 3.3 V / 4096; the 3 asks for three decimal places.
بە 12 یەک هەنگاو 3.3 V / 4096ـە؛ 3 داوای سێ دەکات.
The reference voltage: the top of the rulerڤۆڵتیەی پێوەر: سەری ڕاستەکە
Every reading is a fraction of the reference voltage, so the reference is the length of the ADC's ruler. On an UNO R3, analogReference() can change it: DEFAULT (5 V), INTERNAL (a built-in 1.1 V) or EXTERNAL (the voltage on the AREF pin, 0 to 5 V only). The same 1.00 V reads 204 with the 5 V ruler but 930 with the 1.1 V ruler: a shorter ruler gives finer steps (1.1 V ÷ 1024 ≈ 1.07 mV) — but anything above 1.1 V then reads 1023.
هەموو خوێندنەوەیەک بەشێکە لە ، بۆیە درێژیی ڕاستەکەی ADCـە. لەسەر UNO R3، analogReference() دەتوانێت بیگۆڕێت: DEFAULT (5 V)، INTERNAL (1.1 Vـی ناوخۆیی) یان EXTERNAL ( پینی AREF، تەنیا 0 تا 5 V). هەمان 1.00 V بە ڕاستەی 5 V 204 دەخوێندرێتەوە، بەڵام بە ڕاستەی 1.1 V 930: ڕاستەیەکی کورتتر هەنگاوی وردتر دەدات (1.1 V ÷ 1024 ≈ 1.07 mV) — بەڵام هەر شتێک لە سەرووی 1.1 Vـەوە دەبێتە 1023.
Other boards name the options differently: the UNO R4 has AR_DEFAULT (5 V) and AR_INTERNAL (1.5 V); SAMD boards such as the MKR family have AR_DEFAULT (3.3 V), AR_INTERNAL1V0, AR_INTERNAL1V65, AR_INTERNAL2V23 and AR_EXTERNAL.
بۆردەکانی تر بژاردەکان بە ناوی جیاواز دەنێن: UNO R4 AR_DEFAULT (5 V) و AR_INTERNALـی (1.5 V) هەیە؛ بۆردەکانی SAMD وەک خێزانی MKR AR_DEFAULT (3.3 V)، AR_INTERNAL1V0، AR_INTERNAL1V65، AR_INTERNAL2V23 و AR_EXTERNALـیان هەیە.
The reference voltage: the top of the rulerڤۆڵتیەی پێوەر: سەری ڕاستەکە
Worked example: a TMP36 on A0نموونەیەکی هەنگاوبەهەنگاو: TMP36 لەسەر A0
Put the pieces together on an UNO R3. With its flat face towards you, the TMP36's left leg goes to 5V, its middle leg (the output) to A0 and its right leg to GND. The sketch turns the reading into volts and the volts into °C with the line from Sensitivity: T = (V − 0.5 V) ÷ 0.010 V/°C. Hold the sensor between two fingers and watch it warm:
پارچەکان لەسەر UNO R3 پێکەوە دابنێ. کاتێک ڕووە تەختەکەی بەرەو تۆیە، قاچی چەپی TMP36 دەچێت بۆ 5V، قاچە ناوەڕاستەکەی () بۆ A0 و قاچی ڕاستی بۆ GND. خوێندنەوەکە دەکاتە و دەکاتە °C بە هێڵەکەی هەستیاری: T = (V − 0.5 V) ÷ 0.010 V/°C. لە نێوان دوو پەنجەدا بگرە و سەیری گەرمبوونەکەی بکە:
// TMP36 temperature sensor on A0 (Arduino UNO R3, 5 V reference)
const int tmpPin = A0;
const float CAL_OFFSET = 0.0; // correction in °C from a calibration
void setup() {
Serial.begin(9600);
}
void loop() {
int reading = analogRead(tmpPin);
float volts = reading * 5.0 / 1024.0;
float celsius = (volts - 0.5) / 0.010 + CAL_OFFSET;
Serial.print(reading);
Serial.print(" -> ");
Serial.print(volts, 3);
Serial.print(" V -> ");
Serial.print(celsius, 1);
Serial.println(" C");
delay(1000);
}153 -> 0.747 V -> 24.7 C 154 -> 0.752 V -> 25.2 C 156 -> 0.762 V -> 26.2 C 158 -> 0.771 V -> 27.1 C
Run with the CêIT Arduino checker (analog scenario: A0 = 153, 154, 156, 158). The program prints C instead of °C to keep the Serial text plain.
بە پشکنەری Arduinoـی CêIT جێبەجێ کراوە (سیناریۆی : A0 = 153، 154، 156، 158). لەبری °C تەنیا C چاپ دەکات بۆ ئەوەی دەقی Serial سادە بمێنێتەوە.
Explain the codeڕوونکردنەوەی کۆدەکە
- Lineدێڕی 3
A correction found by calibration, for example −1.2 after an ice-water test.
ڕاستکردنەوەیەک کە بە دۆزراوەتەوە، بۆ نموونە −1.2 دوای تاقیکردنەوەی ئاوی سەهۆڵاوی.
- Lineدێڕی 12
The TMP36 line turned around: 0.5 V at 0 °C, 10 mV per °C.
هێڵی TMP36 بە پێچەوانەوە: 0.5 V لە 0 °C، 10 mV بۆ هەر °C.
- Lineدێڕی 15
print(value, 3): three decimal places.
print(value, 3): سێ .
The readings jump in steps of about 0.5 °C: one ADC step of 4.88 mV is half a degree for a 10 mV/°C sensor. That is still finer than the TMP36's ±2 °C accuracy, so the sensor, not the ADC, limits the result. If you calibrate it (Drift and calibration), put the correction in CAL_OFFSET.
خوێندنەوەکان بە هەنگاوی نزیکەی 0.5 °C باز دەدەن: یەک هەنگاوی ADC کە 4.88 mVـە بۆ 10 mV/°C نیو پلەیە. ئەمە هێشتا لە ±2 °Cـی TMP36 وردترە، بۆیە ، نەک ADC، ئەنجامەکە سنووردار دەکات. ئەگەر بکەیت (لادانی هەستەوەر و ڕێکخستنی پێوان)، ڕاستکردنەوەکە بخەرە ناو CAL_OFFSET.
A pin with nothing on it reads noiseپینێک کە هیچی پێوە نییە ژاوەژاو دەخوێنێتەوە
Pull the wire out of A0 and the numbers do not fall to 0: they wander. An analog pin with nothing connected is a floating input: nothing sets its voltage, so it picks up noise from nearby wires, the other analog inputs and even your hand. The Arduino reference warns about exactly this. Digital pins float in the same way (A pin connected to nothing floats).
وایەرەکە لە A0 دەربهێنە و ژمارەکان بۆ 0 دانابەزن: دەسووڕێنەوە. کە هیچی پێوە نەبەسترابێت ـە: هیچ شتێک دیاری ناکات، بۆیە لە وایەرە نزیکەکان، تر و تەنانەت دەستی تۆوە وەردەگرێت. سەرچاوەی Arduino ڕێک ئاگاداری ئەمە دەکاتەوە. پینە بە هەمان شێوە هەڵدەواسرێن (پینێک کە بە هیچەوە نەبەسترابێت هەڵدەواسرێت).
// Nothing is connected to A1: what does analogRead() give? (Arduino UNO R3)
void setup() {
Serial.begin(9600);
}
void loop() {
Serial.println(analogRead(A1));
delay(300);
}312 287 355 301 410 268
The checker cannot make real noise, so its scenario changes A1 by itself. On a real board the numbers are different every time, and they change when your hand comes near.
پشکنەرەکە ناتوانێت ڕاستەقینە دروست بکات، بۆیە سیناریۆکەی A1 خۆی دەگۆڕێت. لەسەر بۆردی ڕاستەقینە ژمارەکان هەموو جارێک جیاوازن و کاتێک دەستت نزیک دەبێتەوە دەگۆڕێن.
A pin with nothing on it reads noiseپینێک کە هیچی پێوە نییە ژاوەژاو دەخوێنێتەوە
Calmer readings: take an averageخوێندنەوەی ئارامتر: تێکڕا وەربگرە
Even a connected sensor's readings jitter by a step or two. The simplest cure is to take several readings and use their average: random jumps up and down cancel out (Which error can you fix?). Arduino's Smoothing example keeps a running average of the last 10 readings; this shorter sketch averages 16 readings at once:
تەنانەت خوێندنەوەکانی بەستراویش بە هەنگاوێک یان دوو دەلەرزن. سادەترین چارەسەر ئەوەیە چەند خوێندنەوەیەک وەربگریت و تێکڕاکەیان () بەکار بهێنیت: بازدانە هەڕەمەکییەکانی سەر و خوار یەکتر لا دەبەن (کام هەڵە چاک دەکرێت؟). نموونەی Smoothingـی Arduino تێکڕای جووڵاوی دوایین 10 خوێندنەوە دەهێڵێتەوە؛ ئەم کورتترە تێکڕای 16 خوێندنەوە پێکەوە وەردەگرێت:
// Average 16 readings of A0 to calm the noise (Arduino UNO R3)
const int sensorPin = A0;
void setup() {
Serial.begin(9600);
}
void loop() {
long sum = 0; // long: a big sum never overflows
for (int i = 0; i < 16; i++) {
sum += analogRead(sensorPin);
delay(2);
}
int average = sum / 16;
Serial.print("one reading: ");
Serial.print(analogRead(sensorPin));
Serial.print(" average of 16: ");
Serial.println(average);
delay(500);
}one reading: 491 average of 16: 490 one reading: 488 average of 16: 491 one reading: 491 average of 16: 490 one reading: 491 average of 16: 491 one reading: 489 average of 16: 490
Run with the CêIT Arduino checker; its scenario makes A0 jump at random between 488 and 494 every 2 ms. The single reading jumps; the average of 16 stays at 490 or 491.
بە پشکنەری Arduinoـی CêIT جێبەجێ کراوە؛ سیناریۆکەی A0 هەر 2 ms جارێک بە هەڕەمەکی لە نێوان 488 و 494ـدا باز پێ دەدات. تاکە خوێندنەوەکە باز دەدات؛ تێکڕای 16 لەسەر 490 یان 491 دەمێنێتەوە.
Explain the codeڕوونکردنەوەی کۆدەکە
- Lineدێڕی 9
long: an UNOintstops at 32,767, and 64 readings of 1023 would pass it.long:intـی UNO لە 32,767ـدا دەوەستێت و 64 خوێندنەوەی 1023 لێی تێدەپەڕن.- Lineدێڕی 10-13
Read 16 times, 2 ms apart, and add them up.
16 جار بخوێنەوە، 2 ms لە یەکتر و کۆیان بکەرەوە.
- Lineدێڕی 14
Integer division: the average is rounded down.
دابەشکردنی : تێکڕاکە بەرەو خوار نزیک دەکرێتەوە.
Common mistakesهەڵە باوەکان
| Mistakeهەڵە | Betterباشتر |
|---|---|
| Writing the 12-bit range as 0–4096 (or 8 bits as 0–256).نووسینی نرخەکانی 12 وەک 0–4096 (یان هی 8 وەک 0–256). | n bits give 2ⁿ levels, numbered 0 to 2ⁿ − 1: 0–4095, 0–255. ئاست دەدات، لە 0 تا : 0–4095، 0–255. |
| Expecting 0–4095 on an MKR board without asking.چاوەڕوانیی 0–4095 لەسەر بۆردێکی MKR بەبێ داواکردن. | Call analogReadResolution(12); the default is 10 bits.analogReadResolution(12) بانگ بکە؛ بنەڕەت 10 . |
| Assuming every board has a 3.3 V reference (or 5 V).وا بزانیت هەموو بۆردێک 3.3 V (یان 5 V)ـی هەیە. | UNO: 5 V; MKR, Nano 33 and other 3.3 V boards: 3.3 V.UNO: 5 V؛ MKR، Nano 33 و بۆردەکانی تری 3.3 V: 3.3 V. |
| Converting with the old numbers after changing board.گۆڕین بە ژمارە کۆنەکان دوای گۆڕینی بۆرد. | Change both: the reference (5.0 or 3.3) and the levels (1024, 4096…).هەردووکیان بگۆڕە: (5.0 یان 3.3) و ئاستەکان (1024، 4096…). |
| Calling analogReadResolution() on an UNO R3.بانگکردنی analogReadResolution() لەسەر UNO R3. | It does not exist there; the UNO R3 is always 10 bits.لەوێ نییە؛ UNO R3 هەمیشە 10 . |
| Treating analogRead() as volts.وا مامەڵە لەگەڵ analogRead() بکەیت وەک . | It returns a number; volts ≈ reading × Vref ÷ 2ⁿ.ژمارەیەک دەگەڕێنێتەوە؛ ≈ خوێندنەوە × Vref ÷ 2ⁿ. |
| Trusting a reading from an unconnected pin.متمانەکردن بە خوێندنەوەی پینێکی نەبەستراو. | A floating pin reads noise; connect the sensor first. دەخوێنێتەوە؛ سەرەتا ببەستە. |
| More than 5 V (or 3.3 V) on an analog pin.زیاتر لە 5 V (یان 3.3 V) لەسەر . | Never above the board's voltage; bring it down with a voltage divider.هەرگیز لە بۆردەکە زیاتر مەبێت؛ بە دایبەزێنە. |
| A voltage on AREF while the reference is DEFAULT. لەسەر AREF لە کاتێکدا DEFAULTـە. | Call analogReference(EXTERNAL) first.سەرەتا analogReference(EXTERNAL) بانگ بکە. |
| Using int for a big sum of readings.بەکارهێنانی int بۆ کۆی زۆری خوێندنەوەکان. | Use long: an UNO int stops at 32,767.long بەکار بهێنە: intـی UNO لە 32,767ـدا دەوەستێت. |
Exercisesڕاهێنانەکان
A 10-bit ADC has a 3.3 V reference. How many levels does it have, how big is one step, and what reading does 1.50 V give?
ADCـێکی 10 3.3 Vـی هەیە. چەند ئاستی هەیە، یەک هەنگاو چەند گەورەیە و 1.50 V چ خوێندنەوەیەک دەدات؟
Show answerوەڵامەکە پیشان بدە
A TMP36 runs from 3.3 V on an MKR WAN 1310 with analogReadResolution(12). analogRead() gives 930. What is the voltage, and the temperature?
TMP36 بە 3.3 V لەسەر MKR WAN 1310 کار دەکات بە analogReadResolution(12). analogRead() 930 دەدات. و پلەی گەرمییەکە چەندن؟
Show answerوەڵامەکە پیشان بدە
The TMP36 works from 2.7 V, so 3.3 V is fine; keep its output below 3.3 V (it stays under 2.0 V).
TMP36 لە 2.7 Vـەوە کار دەکات، بۆیە 3.3 V باشە؛ لە خوار 3.3 Vـەوە بهێڵەرەوە (لە خوار 2.0 Vـەوە دەمێنێتەوە).
A student moves a sketch from an UNO R3 to an MKR WAN 1310 and adds analogReadResolution(12). The pin is at 2.0 V and reads 2482, but the sketch prints 12.12 V. Which line is wrong, and what should it be?
قوتابییەک لە UNO R3ـەوە دەگوازێتەوە بۆ MKR WAN 1310 و analogReadResolution(12) زیاد دەکات. پینەکە لەسەر 2.0 Vـە و 2482 دەخوێنێتەوە، بەڵام 12.12 V چاپ دەکات. کام دێڕ هەڵەیە و دەبێت چی بێت؟
Hintئاماژە
Two numbers change when the board changes.
کاتێک بۆرد دەگۆڕێت دوو ژمارە دەگۆڕێن.
Show answerوەڵامەکە پیشان بدە
The conversion still uses the UNO's numbers: reading * 5.0 / 1024.0 gives 2482 × 5 ÷ 1024 = 12.12 V. Use the MKR's reference and levels: reading * 3.3 / 4096.0, which gives 2.00 V.
گۆڕینەکە هێشتا ژمارەکانی UNO بەکار دەهێنێت: reading * 5.0 / 1024.0 دەدات 2482 × 5 ÷ 1024 = 12.12 V. و ئاستەکانی MKR بەکار بهێنە: reading * 3.3 / 4096.0، کە 2.00 V دەدات.
A sensor's output stays between 0 and 1.0 V. On an UNO R3, compare analogReference(DEFAULT) with analogReference(INTERNAL): the step, and how many different readings 0–1.0 V can give.
لە نێوان 0 و 1.0 Vـدا دەمێنێتەوە. لەسەر UNO R3، analogReference(DEFAULT) لەگەڵ analogReference(INTERNAL) بەراورد بکە: هەنگاو و ئەوەی 0 تا 1.0 V چەند خوێندنەوەی جیاواز دەدات.
Show answerوەڵامەکە پیشان بدە
- DEFAULT (5 V): step 4.88 mV; 1.0 V reads 204, so only readings 0–204 (205 values) are used.
- INTERNAL (1.1 V): step 1.07 mV; 1.0 V reads 930, so readings 0–930 (931 values): more than four times finer.
- DEFAULT (5 V): هەنگاو 4.88 mV؛ 1.0 V دەبێتە 204، بۆیە تەنیا خوێندنەوەکانی 0 تا 204 (205 نرخ) بەکار دێن.
- INTERNAL (1.1 V): هەنگاو 1.07 mV؛ 1.0 V دەبێتە 930، بۆیە خوێندنەوەکانی 0 تا 930 (931 نرخ): زیاتر لە چوار جار وردتر.
Explain to a friend why randomSeed(analogRead(A0)) gives different random numbers after each reset only when A0 is unconnected.
بۆ هاوڕێیەکت ڕوون بکەرەوە بۆچی randomSeed(analogRead(A0)) تەنیا کاتێک A0 نەبەستراوە دوای هەر سەرلەنوێ دەستپێکردنێک جیاواز دەدات.
Show answerوەڵامەکە پیشان بدە
A floating pin reads noise, so each start gives a different seed and random() starts at a different point. With a sensor connected, the reading is steady, the seed is almost the same every time and the 'random' numbers repeat.
دەخوێنێتەوە، بۆیە هەر دەستپێکردنێک تۆوێکی جیاواز دەدات و random() لە خاڵێکی جیاوازەوە دەست پێ دەکات. کاتێک بەسترابێت، خوێندنەوەکە جێگیرە، تۆوەکە هەموو جارێک نزیکەی هەمانە و دووپاتە دەبنەوە.
Summaryپوختە
- Analog sensors give a continuous voltage and need A/D conversion; digital sensors send bits.
- The MCU's built-in ADC turns the voltage on an analog pin into a number; on an UNO six pins share one ADC.
- n bits give 2ⁿ levels, 0 to 2ⁿ − 1: 0–255, 0–1023, 0–4095, 0–16383.
- One step = Vref ÷ 2ⁿ: 4.88 mV on an UNO R3; reading = ⌊Vin × 2ⁿ ÷ Vref⌋; volts ≈ reading × Vref ÷ 2ⁿ.
- analogRead() returns a number, about 100 µs per read on ATmega boards; 10 bits by default on every board, more with analogReadResolution() (MKR 12, UNO R4 14).
- The reference is the ruler: 5 V on the UNO, 3.3 V on MKR boards; analogReference() changes it, carefully with AREF.
- A floating pin reads noise; averaging several readings calms a jittery sensor.
- بەردەوام دەدەن و پێویستیان بە گۆڕینی A/D هەیە؛ دەنێرن.
- ADCـی ناوخۆیی MCU دەکاتە ژمارە؛ لەسەر UNO شەش پین یەک ADC بەکار دەهێنن.
- ئاست دەدات، 0 تا : 0–255، 0–1023، 0–4095، 0–16383.
- یەک هەنگاو = Vref ÷ 2ⁿ: 4.88 mV لەسەر UNO R3؛ خوێندنەوە = ⌊Vin × 2ⁿ ÷ Vref⌋؛ ≈ خوێندنەوە × Vref ÷ 2ⁿ.
- analogRead() ژمارەیەک دەگەڕێنێتەوە، نزیکەی 100 µs بۆ هەر خوێندنەوەیەک لەسەر بۆردەکانی ATmega؛ لەسەر هەموو بۆردێک بە شێوەی بنەڕەت 10 ، زیاتر بە analogReadResolution() (MKR 12، UNO R4 14).
- ڕاستەکەیە: 5 V لەسەر UNO و 3.3 V لەسەر بۆردەکانی MKR؛ analogReference() دەیگۆڕێت، بە وریاییەوە لەگەڵ AREF.
- دەخوێنێتەوە؛ تێکڕای چەند خوێندنەوەیەک لەرزۆک ئارام دەکاتەوە.
Why does a 10-bit ADC top out at 1023 and not 1024?بۆچی بەرزترین نرخی ADCـێکی 10 بیتی 1023ـە نەک 1024؟
It has 1024 levels, and counting starts at 0, so the last one is 1023.
1024 ئاستی هەیە و ژماردن لە 0ـەوە دەست پێ دەکات، بۆیە دوایینیان 1023ـە.
What two numbers must you change when a sketch moves from an UNO to an MKR board with 12 bits?کاتێک سکێچێک لە UNOـەوە دەچێت بۆ بۆردێکی MKR بە 12 بیت، دەبێت چ دوو ژمارەیەک بگۆڕیت؟
The reference (5.0 to 3.3) and the levels (1024 to 4096). Also remember analogReadResolution(12).
(5.0 بۆ 3.3) و ئاستەکان (1024 بۆ 4096). هەروەها analogReadResolution(12) لەبیر مەکە.
Is a 12-bit reading of a ±2 °C sensor accurate to 0.012 °C?ئایا خوێندنەوەیەکی 12 بیتیی هەستەوەرێکی ±2 °C تا 0.012 °C ڕاستە؟
No. 0.012 °C is only the resolution; the sensor's accuracy, ±2 °C, is the real limit.
نەخێر. 0.012 °C تەنیا ؛ ، ±2 °C، سنوورە ڕاستەقینەکەیە.
Lesson complete!وانەکە تەواو بوو!
Well done. Review the key terms, then go on to the next lesson.دەستخۆش. سەیرێکی زاراوە سەرەکییەکان بکەرەوە، پاشان بڕۆ بۆ وانەی داهاتوو.
Key termsزاراوە سەرەکییەکان
Sensing Light with an LDRهەستکردن بە ڕووناکی بە LDR
Related lecturesوانە پەیوەندیدارەکان
- Accuracy, Precision, Range: Reading a Sensor's Data Sheetڕاستیی پێوان، وردیی پێوان و مەودای پێوان: خوێندنەوەی پەڕەی تایبەتمەندییەکانی هەستەوەرێک
- Arduino Boards and the Arduino IDEبۆردەکانی Arduino و Arduino IDE
- Lab: Buttons, INPUT_PULLUP and Debouncingتاقیگە: دوگمەکانی پەستان، INPUT_PULLUP و لابردنی هەڵبەزینەوە
- Lab: Dimming with PWM and Beeping with tone()تاقیگە: کزکردن بە PWM و بیپ بە tone()
- Sensing Light with an LDRهەستکردن بە ڕووناکی بە LDR
- Temperature and Humidity: the DHT11 and a 16x2 LCDپلەی گەرمی و شێ: DHT11 و LCDـێکی 16x2
- Analog and Digital Signalsسیگناڵەکانی ئەنالۆگ و دیجیتاڵ
- Number Systems and Place Valueسیستەمە ژمارەییەکان و بەهای خانەیی
References and further readingسەرچاوەکان و خوێندنەوەی زیاتر
- Arduino language reference: analogRead() (board table, 5 V / 1024 = 4.9 mV, about 100 µs, unconnected pins fluctuate)
- Arduino language reference: analogReadResolution() (defaults to 10 bits; extra bits padded with zeros, fewer bits discarded)
- Arduino language reference: analogReference() (AVR, Renesas UNO R4 and SAMD options; AREF warnings)
- Arduino language reference: randomSeed() (analogRead() on an unconnected pin as a seed)
- Arduino docs: UNO R4 Minima ADC resolution (10-bit default, 12- and 14-bit with analogReadResolution)
- Arduino docs: MKR WAN 1310 tech specs (7 analog inputs, ADC 8/10/12 bit, 3.3 V I/O)
- Arduino docs: UNO Rev3, Nano and Mega 2560 tech specs (analog inputs 6, 8 and 16; 5 V I/O)
- Arduino built-in example: Read Analog Voltage (sensorValue * (5.0 / 1023.0))
- Arduino built-in example: Smoothing (running average of 10 readings)
- ArduinoCore-avr: Arduino.h (analogRead and analogReference, no analogReadResolution)
- ArduinoCore-samd: wiring_analog.c (read resolution 10 bits by default, ADC 8/10/12 bits)
- Analog Devices TMP35/TMP36/TMP37 data sheet (750 mV at 25 °C, 10 mV/°C), copy hosted by Adafruit
- Adafruit: Using a TMP36 temperature sensor (pinout with the flat face towards you; Temp = (Vout − 500 mV) / 10)
This lecture is a first edition. The Kurdish text and terminology are waiting for review by Kurdish IT teachers.ئەم وانەیە چاپی یەکەمە. دەقە کوردییەکە و زاراوەکانی چاوەڕێی پێداچوونەوەی مامۆستایانی کوردی بواری IT ن.