SEARCH
TOOLBOX
LANGUAGES
modified on 18 September 2014 at 15:26 ••• 22,496 views

05-04 LoggingData

From Manuals

(Difference between revisions)
Jump to: navigation, search
Support (Talk | contribs)
(Created page with 'This example reads an analog voltage and transfers the reading to a terminal running on a personal computer. /*Program Example 5.4: Reads input voltage through the ADC, and tr…')
Newer edit →

Revision as of 15:30, 14 August 2014

This example reads an analog voltage and transfers the reading to a terminal running on a personal computer.

/*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
  }
}


BAM210
Schematic for example 05-04