Lysregulering / Mbed 2 deprecated TESTDIOPOT

Dependencies:   XBeeLib mbed

Fork of TESTSENDIO by Lysregulering

Files at this revision

API Documentation at this revision

Comitter:
andreasbirkeland97
Date:
Fri Feb 16 17:09:39 2018 +0000
Parent:
0:8142893960b0
Commit message:
zdv

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 8142893960b0 -r d752dab97a81 main.cpp
--- a/main.cpp	Fri Feb 16 12:52:47 2018 +0000
+++ b/main.cpp	Fri Feb 16 17:09:39 2018 +0000
@@ -1,18 +1,26 @@
 #include "XBeeLib.h"
+#include "mbed.h"
+
+AnalogIn ai(p20);
+Serial pc(USBTX, USBRX);
   
 using namespace XBeeLib;
  
 int main()
 {
-  XBeeZB xbee = XBeeZB(RADIO_TX, RADIO_RX, RADIO_RESET);
-     RadioStatus radioStatus;
-
-    
+XBeeZB xbee = XBeeZB(RADIO_TX, RADIO_RX, RADIO_RESET);
+RadioStatus radioStatus;
+float voltage;
  while(1){
     RemoteXBeeZB remoteDevice = RemoteXBeeZB(0x0013A20041642F34);
-    radioStatus = xbee.set_pin_config(remoteDevice, XBeeZB::DIO4, DigitalOutHigh);
-    wait(0.01);
-    radioStatus = xbee.set_pin_config(remoteDevice, XBeeZB::DIO4, DigitalOutLow);
-    wait(0.01);
+    voltage = ai * 16;
+    if(voltage > 2){
+            radioStatus = xbee.set_pin_config(remoteDevice, XBeeZB::DIO4, DigitalOutHigh);
+            pc.printf("LYS");
+        }
+        else {
+            radioStatus = xbee.set_pin_config(remoteDevice, XBeeZB::DIO4, DigitalOutLow);
+            pc.printf("IKKE LYS");}
+
 }
-}
\ No newline at end of file
+}