test

Dependencies:   WIZnetInterface mbed

Files at this revision

API Documentation at this revision

Comitter:
xaionaro
Date:
Sat Aug 08 16:37:57 2015 +0000
Commit message:
initial

Changed in this revision

WIZnetInterface.lib 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.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WIZnetInterface.lib	Sat Aug 08 16:37:57 2015 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/teams/WIZnet/code/WIZnetInterface/#3b64df29662f
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Aug 08 16:37:57 2015 +0000
@@ -0,0 +1,42 @@
+#include "mbed.h"
+#include "UDPSocket.h"
+#include "Endpoint.h"
+#include "EthernetInterface.h"
+ 
+AnalogIn analog_value(A0);
+
+#define ETH0_RST    D5
+#define ETH0_CS     D10
+#define ETH0_MOSI   D11
+#define ETH0_MISO   D12
+#define ETH0_SCK    D13
+
+Endpoint remote;
+EthernetInterface eth0(ETH0_MOSI, ETH0_MISO, ETH0_SCK, ETH0_CS, ETH0_RST);
+UDPSocket udp0;
+ 
+DigitalOut led(LED1);
+
+int main() {
+    remote.set_address("192.168.91.1", 31415);
+    eth0.connect();
+    udp0.set_blocking(false);
+    
+    float meas;
+    
+    printf("\nAnalogIn example\n");
+    
+    while(1) {
+        meas = analog_value.read(); // Converts and read the analog input value (value from 0.0 to 1.0)
+        meas = meas * 3300; // 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;
+        }
+        udp0.sendTo(remote, (char *)&meas, sizeof(meas));
+        //wait(0.2); // 200 ms
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sat Aug 08 16:37:57 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/b9ad9a133dc7
\ No newline at end of file