Slave

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
tamamfirdaus
Date:
Tue Sep 24 14:15:29 2019 +0000
Commit message:
Slave

Changed in this revision

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
diff -r 000000000000 -r 47259286a496 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Sep 24 14:15:29 2019 +0000
@@ -0,0 +1,36 @@
+//Ini Kodingan untuk mengirim data int signed (int32_t) antar nukleo
+//Slave yg ngirim data
+//bisa error kalo pencet tombolnya kecepetan datanya jadi beda
+#include "mbed.h"
+
+Serial slave(PC_10, PC_11);
+DigitalIn BlueButton(USER_BUTTON);  // This is Blue-Button and is on NUCLEO-L153RE
+ 
+#define Pressed 0                   
+#define NotPressed 1
+int32_t numberToSend;              //data yang dikirim
+double  a   = 2137.32422;
+uint8_t A,B,C,D;                    //variabel untuk convert int ke char
+uint32_t temp;                      //temporary int yg dishift
+
+int main(){
+    while(1){
+        if (BlueButton == Pressed){
+            numberToSend    = (int32_t) 2245.24556;//(a*1000);
+            temp = numberToSend>>24;
+            A = (uint8_t) temp;
+            temp = (numberToSend<<8)>>24;
+            B = (uint8_t) temp;
+            temp = (numberToSend<<16)>>24;
+            C = (uint8_t) temp;
+            temp = (numberToSend<<24)>>24;
+            D = (uint8_t) temp;
+            slave.putc(A);
+            slave.putc(B);
+            slave.putc(C);
+            slave.putc(D);
+            }
+        
+    }
+}
+    
\ No newline at end of file
diff -r 000000000000 -r 47259286a496 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Sep 24 14:15:29 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/e95d10626187
\ No newline at end of file