Example code

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
MadhuraT
Date:
Wed Mar 06 23:04:28 2019 +0000
Parent:
1:ce08f1d8140c
Commit message:
EXAMPLE CODE

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r ce08f1d8140c -r 384c0e3bb7ab main.cpp
--- a/main.cpp	Sat Jul 08 05:01:19 2017 +0000
+++ b/main.cpp	Wed Mar 06 23:04:28 2019 +0000
@@ -20,8 +20,12 @@
 pc.printf("Hello World !\n");
 ------------------------------------------------------------------------------*/
 
-DigitalOut led(LED1);
+DigitalOut led(LED2);
+char buf[256];
+CAN can1 (PB_8,PB_9);
+char counter=0;
 
+Serial pc(SERIAL_TX, SERIAL_RX);
 int main()
 {
     int i = 1;
@@ -30,7 +34,20 @@
 
     while(1) {
         wait(1); // 1 second
-        led = !led; // Toggle LED
-        printf("This program runs since %d seconds.\n", i++);
+        //led = !led; // Toggle LED
+        pc.gets(buf,3);
+        if(buf[0] == 'f')
+        {
+            led =1;
+            can1.write(CANMessage(1337, &counter,1));
+        }
+        else if (buf[0] == 'g')
+        {
+            led =0;
+        }
+            
+        pc.printf("buffer is %s",buf);
+        
+        //printf("This program runs since %d seconds.\n", i++);
     }
 }