SEARCH
TOOLBOX
LANGUAGES
modified on 14 August 2014 at 15:30 ••• 22,542 views

05-04 LoggingData

From Manuals

Revision as of 15:30, 14 August 2014 by Support (Talk | contribs)
(diff) ← Older revision | Current revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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