Introduction of ADC
- ADC (Analog to Digital Converter) component is capable of coverting analog signal to digital signal. The ADC component of Ameba is of 12-bit precision, and its effective range of measurement is 0V ~ 3.3V, so the minimum measurable difference i voltage is 3.3V / (2^12-1) = 8mV.
- Ameba x 1
- 10KΩ Potentiometer (Variable Resistor) x 1, if you don't have potentiometer in hand, the 3V3 & 5V on Ameba can be used instead.
In this example, we use ADC to get the voltage value.Open the sample code in "File" -> "Example" -> "01.Basics" -> "ReadAnalogVoltage"
To read data from Ameba, we have to find out the serial port connected to Ameba.
Open "Device Manager" in Windows, find "mbed Serial Port". For example in the figure, we can find "mbed Serial Port(COM15)", then "COM15" is the port number connected to Ameba.
Next, we connect Ameba to the correct port in Arduino IDE. Go to "Tools" -> "Port", and select the port number (here we select port COM15).
When we want to read the message output from Ameba, it is necessary that the port is set to the correct port connecting to Ameba:
Then we open the "Serial Monitor" in "Tools" -> "Serial Monitor":
In the Serial Monitor, Ameba prints the voltage value output from A0 continuously. We can adjust the potentiometer to change the output.
We use analogRead(pin) to read the value from the specified analog pin directly: