El-POM1001 / Mbed 2 deprecated LAB10_Oppgave4

Dependencies:   mbed

Fork of LAB10_Oppgave3 by EL-POM1001

Files at this revision

API Documentation at this revision

Comitter:
madmonkeyman82
Date:
Thu Nov 05 16:21:25 2015 +0000
Parent:
1:05b1d2a203e5
Commit message:
first

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Wed Nov 04 21:02:48 2015 +0000
+++ b/main.cpp	Thu Nov 05 16:21:25 2015 +0000
@@ -2,19 +2,43 @@
 
 Serial serial3(PB_9, PB_8); // tx, rx
 Serial pc(USBTX, USBRX);    // tx, rx
+InterruptIn button(PC_13);
+DigitalOut led(PA_5);
 
 void serial3Rx()
-{    pc.putc(serial3.getc());
+{
+  char rx_temp = serial3.getc();
+  pc.putc(rx_temp);
+  if(rx_temp == 'L')
+  {
+    led=1;
+  }
+  else
+  {
+   led=0;
+  }
 }
 
 void pcRx()
 {    serial3.putc(pc.getc());
 }
 
+void buttonpress()
+{
+    serial3.putc('M');
+}
+
+void buttonrelease()
+{
+    serial3.putc('L');
+}
 int main()
 {
     serial3.attach(&serial3Rx);
     pc.attach(&pcRx);
+    button.rise(&buttonpress);
+    button.fall(&buttonrelease);
+    button.enable_irq();
 
     while(1) {
         wait(1);