New group

Dependencies:   mbed

Fork of TAIST_modbus by Supachai Vorapojpisut

Revision:
1:f84cb7cea5ea
Parent:
0:f306cb0263a6
Child:
2:6a3ab2abe970
diff -r f306cb0263a6 -r f84cb7cea5ea main.cpp
--- a/main.cpp	Wed Mar 14 06:17:48 2018 +0000
+++ b/main.cpp	Wed Mar 14 07:28:50 2018 +0000
@@ -2,23 +2,40 @@
 #include "modbus.h"
 
 DigitalOut myled(LED1);
+InterruptIn button(USER_BUTTON);
 RawSerial pc(USBTX, USBRX);
 
+float cunt=0.0;
+
 void serial_callback()
 {
     uint8_t frame[6];
-    
     char ch = pc.getc();
-    if (modbus_parser(ch, frame)) {
-        
+    if (modbus_parser(ch, frame)) {   
     }
 }
 
+void pressed()
+{
+    cunt=cunt+0.1;
+    wait(0.1);
+}
+
+void released()
+{
+    cunt=0;
+}
+
 int main() {
     // setup code
     pc.attach(serial_callback);
+    
     // 1. button code
+    button.fall(&pressed);  
+    button.rise(&released);
+    
     // 2. timer code
+    
     while(1) {
         // loop code
         myled = 1; // LED is ON