ADC-TEST

Dependencies:   mbed-stm32l0/l1-src

Files at this revision

API Documentation at this revision

Comitter:
lzbpli
Date:
Fri Apr 15 02:31:47 2016 +0000
Commit message:
ADC-TEST

Changed in this revision

adc.cpp Show annotated file Show diff for this revision Revisions of this file
adc.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-stm32l0l1-src.lib Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 8e51fe87bd77 adc.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/adc.cpp	Fri Apr 15 02:31:47 2016 +0000
@@ -0,0 +1,24 @@
+#include "adc.h"
+#include "mbed.h"
+
+AnalogIn analog_value(PA_0);
+
+DigitalOut led(PB_3);
+
+float analogvalue()
+{
+    float meas;
+  //  RE= 0;
+//    DE = 0;
+  //  printf("\nAnalogIn example\n");    
+        meas = analog_value.read(); // Converts and read the analog input value (value from 0.0 to 1.0)
+        meas = meas * 10000; // Change the value to be in the 0 to 3300 range
+   //     printf("measure = %.0f mV\n", meas);
+        if (meas > 2000) { // If the value is greater than 2V then switch the LED on
+          led = 1;
+        }
+        else {
+          led = 0;
+        }
+        return meas;
+}
diff -r 000000000000 -r 8e51fe87bd77 adc.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/adc.h	Fri Apr 15 02:31:47 2016 +0000
@@ -0,0 +1,7 @@
+#ifndef __LORA_ADC_H__
+#define __LORA_ADC_H__
+
+
+float analogvalue();
+
+#endif
diff -r 000000000000 -r 8e51fe87bd77 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Apr 15 02:31:47 2016 +0000
@@ -0,0 +1,31 @@
+#include "mbed.h"
+#include "adc.h" 
+#include "string"
+
+//using namespace matsujirushi;
+
+RawSerial pc(PB_6, PB_7);
+
+//AnalogIn analog_value(A0);
+ 
+//DigitalOut led(LED1);
+//DigitalOut RE(D8);
+//DigitalOut DE(D9);
+
+
+int main() {
+//    RE= 1;
+//    DE = 1;
+    pc.baud(9600);
+   // line.puts("unknown.");
+ //   line.puts("\nAnalogIn example\n");
+  //  printf("measure = %.0f mV\r\n", analogvalue()); 
+ //   line.attachReadLine(readLineFunc);    
+    while(1) {
+        printf("measure = %.0f mV\r\n", analogvalue()); 
+      //  line.task();
+     //   line.puts("AnalogIn example\n");
+     //   line.printf("measure = %.0f mV\r\n", analogvalue()); 
+        wait(0.2); // 200 ms
+    }
+}
diff -r 000000000000 -r 8e51fe87bd77 mbed-stm32l0l1-src.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-stm32l0l1-src.lib	Fri Apr 15 02:31:47 2016 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/lzbpli/code/mbed-stm32l0l1-src/#cdb71f051ab2