Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
00001 #include <stdio.h> 00002 #include "mbed.h" 00003 Serial pc(USBTX, USBRX); 00004 AnalogIn analogValue(A2); 00005 DigitalIn userButton(USER_BUTTON); 00006 DigitalOut led(LED1); 00007 00008 // Calculate the corresponding acquisition measure for a given value in mV 00009 #define MV(x) ((0xFFF*x)/3300) 00010 00011 int main( void) { 00012 led = 0; 00013 pc.baud(9600); 00014 int count = 0; 00015 bool enFlag = true; 00016 while (1) { 00017 00018 count++; 00019 if (userButton == 0) { 00020 enFlag = (enFlag == true) ? false : true; 00021 //pc.close(); 00022 } 00023 if (enFlag) { 00024 unsigned short meas = (analogValue.read_u16()); 00025 //float fl = analogValue.read() * 3300; 00026 //float final = (float) 3300* (float) meas / 65535 ; // normal 0.0008 or 3.3v-3300mV 0,8058608058608059 3300/4095 00027 pc.printf("%d; 16bit %hu val in mV: %d \n", count, 00028 meas, ((meas * 3300) / 0xFFFF)); //, (int) fl); 00029 00030 } 00031 00032 led = !led; 00033 00034 wait(1.5f); 00035 } 00036 return 0; 00037 }
Generated on Sat Jul 16 2022 14:41:52 by
1.7.2