Difference between revisions of "Lesson 9--Microduino "DIY Multimeter""
(→Video) |
(→Result) |
||
(8 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
+ | {{Language|第九课--Microduino_做0-5V量程的电压表(万用表的使用)}} | ||
{| style="width: 800px;" | {| style="width: 800px;" | ||
|- | |- | ||
| | | | ||
==Objective== | ==Objective== | ||
− | + | Previously, we introduced analogRead() and its return values of 0~1024. In this lesson, we will use the analog port of [[Microduino-Core]] to make a multimeter with the range of 0-5 V. | |
− | ''' | + | '''Important: The design of this experiment does not have an effective protection circuit. Please do not use more than two AA batteries and do not use the circuit to measure a lithium battery or any other power supply!''' |
==Equipment== | ==Equipment== | ||
Line 11: | Line 12: | ||
*'''[[Microduino-FT232R]]''' | *'''[[Microduino-FT232R]]''' | ||
*Other hardware equipment | *Other hardware equipment | ||
− | ** | + | **1x AA Battery |
− | **Breadboard | + | **1x Box of breadboard jumper wires |
− | **1kΩ resistor | + | **1x Breadboard |
− | **USB Data cable | + | **1x 1kΩ resistor |
+ | **1x USB Data cable | ||
− | == | + | [[File:lesson9All.jpg|600px|center|thumb]] |
+ | |||
+ | ==Experiment Schematic== | ||
[[File:less0n9-schematic.jpg|center|600px|thumb]] | [[File:less0n9-schematic.jpg|center|600px|thumb]] | ||
− | |||
==Program== | ==Program== | ||
Line 25: | Line 28: | ||
void setup() | void setup() | ||
{ | { | ||
− | Serial.begin( | + | Serial.begin(9600); //Set baud rate 9600 |
} | } | ||
void loop() | void loop() | ||
Line 31: | Line 34: | ||
int V1 = analogRead(A0); | int V1 = analogRead(A0); | ||
− | // Read the voltage | + | // Read the voltage data from A0 and store it in variable V1. The voltage range is 0-5V and returns values 0-1024. |
float vol = V1*(5.0 / 1023.0); | float vol = V1*(5.0 / 1023.0); | ||
− | //Convert the V1 to | + | //Convert the V1 to the voltage value and store it in vol |
if (vol == temp) | if (vol == temp) | ||
//Use to filter duplicate data, Only the voltage value and the last isn't same then output the value. | //Use to filter duplicate data, Only the voltage value and the last isn't same then output the value. | ||
Line 48: | Line 51: | ||
} | } | ||
</source> | </source> | ||
− | We | + | We didn't use the map() function in this example, but you can try it yourself! |
==Result== | ==Result== | ||
− | When the measured voltage | + | When the measured voltage changes, refresh the data every second. It is normal if there is a difference between two measurements of the same battery. This is because this is still simply a low accuracy test. If you need a high accuracy test, you can take a look at: |
− | |||
http://www.hacktronics.com/Tutorials/arduino-current-sensor.html | http://www.hacktronics.com/Tutorials/arduino-current-sensor.html | ||
+ | |||
+ | [[File:lesson9Result.jpg|600px|center|thumb]] | ||
+ | |||
==Video== | ==Video== | ||
+ | https://www.youtube.com/watch?v=bhaj_QhRE-Q | ||
|} | |} | ||
− | |||
− |
Latest revision as of 00:49, 27 July 2015
Language: | English • 中文 |
---|
ObjectivePreviously, we introduced analogRead() and its return values of 0~1024. In this lesson, we will use the analog port of Microduino-Core to make a multimeter with the range of 0-5 V. Important: The design of this experiment does not have an effective protection circuit. Please do not use more than two AA batteries and do not use the circuit to measure a lithium battery or any other power supply! Equipment
Experiment SchematicProgramfloat temp; // Define a float variable temp to save data.
void setup()
{
Serial.begin(9600); //Set baud rate 9600
}
void loop()
{
int V1 = analogRead(A0);
// Read the voltage data from A0 and store it in variable V1. The voltage range is 0-5V and returns values 0-1024.
float vol = V1*(5.0 / 1023.0);
//Convert the V1 to the voltage value and store it in vol
if (vol == temp)
//Use to filter duplicate data, Only the voltage value and the last isn't same then output the value.
{
temp = vol; //Compared, then store in temp variable "temp"
}
else
{
Serial.print(vol); //Serial output voltage, nowrap
Serial.println(" V"); //Serial output character "V", and wrap
temp = vol;
delay(1000); //Wait for 1s, use to refresh the data
}
} We didn't use the map() function in this example, but you can try it yourself! ResultWhen the measured voltage changes, refresh the data every second. It is normal if there is a difference between two measurements of the same battery. This is because this is still simply a low accuracy test. If you need a high accuracy test, you can take a look at: http://www.hacktronics.com/Tutorials/arduino-current-sensor.html Video |