05-04 LoggingData
From Manuals
This example reads an analog voltage and transfers the reading to a terminal running on a personal computer.
The signals used for this example are listed below:
| Signal | LPC4330 PIN NAME | BAM210E | BAM210 | BAM200E | BAM200 | Used for |
| A0 | P7_4 | J8-1 | J8-1 | S4-3 | S4-3 | Potentiometer |
| USBTX | P2_10 | MBED-HDK | MBED-HDK | S10-4 | n/p | MBED-HDK Serial RX |
| USBRX | P2_11 | MBED-HDK | MBED-HDK | s10-5 | n/p | MBED-HDK Serial TX |
The following schematic can be used to build the circuit with a BAM210E or BAM210.
/*Program Example 5.4: Reads input voltage through the ADC, and transfers to PC terminal
*/
#include "mbed.h"
Serial pc(USBTX, USBRX); //enable serial port which links to USB
AnalogIn Ain(A0);
float ADCdata;
int main() {
pc.printf("ADC Data Values...\n\r"); //send an opening text message
while(1) {
ADCdata=Ain;
wait(0.5);
pc.printf("%1.3f \n\r",ADCdata); //send the data to the terminal
}
}
The terminal window was captured in the image below.
The following image shows the built circuit on a BAM210E.



