P3E4

Dependencies:   mbed

Revision:
0:e2ffc65371db
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Sep 26 18:43:55 2018 +0000
@@ -0,0 +1,36 @@
+#include "mbed.h"
+#include <stdint.h>
+BusIn A(PB_13,PC_4,PA_10,PB_3);
+BusIn B(D4,D5,D6,D7);
+BusOut Sal(D8,D9,D10,D11,D12,D13,D14,D15);
+DigitalIn ent1(PA_12),ent2(PA_11),ent3(PB_12),ent4(PB_2);
+
+int main() {
+    int a,b,s;
+    while (true) {
+        a=A;
+        b=B;
+        if(ent1==1){
+            s=a+b;
+            }
+        else if(ent2==1){
+            if (a>b){
+                s=a-b;}
+            else{
+                s=b-a;}
+            }
+        else if(ent3==1){
+            s=a*b;
+            }
+        else if(ent4==1){
+            if (a>b){
+                s=a/b;}
+            else{
+                s=b/a;}
+            }
+        else{
+            s=b;
+            }
+        Sal=s;       
+    }
+}
\ No newline at end of file