Maple Lesson 08 - A multimeter with the range of 0 to 5 volts
ObjectiveWe have introduced the reading (0-1024) of the analog port before. Now, we will use the analog port of microduino to make a voltmeter with the range of 0-5 V. Notice: The circuit design of the experiment has no relatively complicated protection circuit. So please don't use more than two AA batteries and don't use the circuit to measure the lithium battery or other power supply!! EquipmentMicroduino-CoreSTM32 is an ARM development board using STM32F103CBT6 chip. It use special Upin7 interface, the size is similar with a coin and fully compatible other Microduino modules.
==Schematic Programconst int analogInPin = 14;
float sensorValue = 0; // value read from the port
float Voltage=0;
void setup() {
pinMode(analogInPin, INPUT_PULLDOWN);
//Use the internal pull-down, and set the GND to measure port which can avoid the Interface dangling received interference.
}
void loop() {
// read the analog in value:
sensorValue = analogRead(analogInPin);
// map it to the range of the analog out:
Voltage = sensorValue*5/4095;
SerialUSB.print("Voltage = ");
SerialUSB.print(Voltage);
SerialUSB.println("V ");
delay(500);
}
Serial monitorUse to communicate between Maple and STM32.
ResultWhen the measured voltage changed, refresh the date every 1s. If there is a gap between two voltage values, this is normal. Because this is a low accuracy test. Video |