beep keypad

Dependencies:   TextLCD mbed

Fork of Autus by Umair Aftab

Files at this revision

API Documentation at this revision

Comitter:
redplam
Date:
Sat Apr 12 20:55:13 2014 +0000
Parent:
4:0cd0c7fe0682
Commit message:
mykeypad;

Changed in this revision

ESC.lib Show diff for this revision Revisions of this file
buzz.cpp Show diff for this revision Revisions of this file
buzz.h Show diff for this revision Revisions of this file
buzzer/buzz.cpp Show annotated file Show diff for this revision Revisions of this file
buzzer/buzz.h Show annotated file Show diff for this revision Revisions of this file
keypad.cpp Show diff for this revision Revisions of this file
keypad.h Show diff for this revision Revisions of this file
keypad/keypad.cpp Show annotated file Show diff for this revision Revisions of this file
keypad/keypad.h Show annotated file Show diff for this revision Revisions of this file
led.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 0cd0c7fe0682 -r 780a0888c3f2 ESC.lib
--- a/ESC.lib	Sun Apr 06 04:10:57 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/users/MitchJCarlson/code/ESC/#6ef05596f0e7
diff -r 0cd0c7fe0682 -r 780a0888c3f2 buzz.cpp
--- a/buzz.cpp	Sun Apr 06 04:10:57 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,20 +0,0 @@
-#include "mbed.h"
-                                //set timer 1ms
-int beep_delay;
-DigitalOut myled(PTE5);
-void timer1(void)        //interrupt every 1ms
-{
-    beep_delay=beep_delay-1;
-}
-void beep(float freq,int time)
-{
-
-    beep_delay=time;
-
-    do {
-        myled = 1;
-        wait(freq);
-        myled = 0;
-        wait(freq);
-    } while(beep_delay!=0);
-}
\ No newline at end of file
diff -r 0cd0c7fe0682 -r 780a0888c3f2 buzz.h
--- a/buzz.h	Sun Apr 06 04:10:57 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-void timer1(void);
-void beep(float freq,int time);
\ No newline at end of file
diff -r 0cd0c7fe0682 -r 780a0888c3f2 buzzer/buzz.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/buzzer/buzz.cpp	Sat Apr 12 20:55:13 2014 +0000
@@ -0,0 +1,20 @@
+#include "mbed.h"
+                                //set timer 1ms
+int beep_delay;
+DigitalOut myled(PTE5);
+void timer1(void)        //interrupt every 1ms
+{
+    beep_delay=beep_delay-1;
+}
+void beep(float freq,int time)
+{
+
+    beep_delay=time;
+
+    do {
+        myled = 1;
+        wait(freq);
+        myled = 0;
+        wait(freq);
+    } while(beep_delay!=0);
+}
\ No newline at end of file
diff -r 0cd0c7fe0682 -r 780a0888c3f2 buzzer/buzz.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/buzzer/buzz.h	Sat Apr 12 20:55:13 2014 +0000
@@ -0,0 +1,2 @@
+void timer1(void);
+void beep(float freq,int time);
\ No newline at end of file
diff -r 0cd0c7fe0682 -r 780a0888c3f2 keypad.cpp
--- a/keypad.cpp	Sun Apr 06 04:10:57 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,178 +0,0 @@
-#include "mbed.h"
-#include "buzz.h"
-//#include "buzz.cpp"
-
-
-//#include "TextLCD.h"
-//extern void timer1(void);
-//extern void beep(float freq,int time);
-
-BusIn colonne(PTE2,PTE3,PTE4,PTA16,PTC0,PTC7);
-BusOut righe(PTA1,PTA2,PTB10,PTB9,PTB8);
-//TextLCD lcd(PTE5,PTE4,PTE3,PTE2,PTB11,PTB10);
-
-char Keypad(void)
-{
-    char key = 100;
-  //  righe.write(31);//11111
-  //  switch(colonne) {
-  //      case 31:
-  //          key = 1;
-  //          break;//011111
-  //      case 47:
-  //          key = 2;
-  //          break;//101111
-  //      case 55:
-  //          key = 3;
-  //          break;//110111
-  //      case 59:
-  //          key = 4;
-  //          break;//111011
-  //      case 61:
-  //          key = 5;
-  //          break;//111101
-  //      case 62:
-  //          key = 6;
-  //          break;//111110
- //   }
-    righe.write(30);//11110
-    switch(colonne) {
-        case 31:
-            key = 7;
-            beep(0.0002,100);
-            break;//011111
-        case 47:
-            key = 8;
-            beep(0.0002,100);
-            break;//101111
-        case 55:
-            key = 9;
-            beep(0.0002,100);
-            break;//110111
-        case 59:
-            key = 10;
-            beep(0.0002,100);
-            break;//111011
-        case 61:
-            key = 11;
-            beep(0.0002,100);
-            break;//111101
-        case 62:
-            key = 12;
-            beep(0.0002,100);
-            break;//111110
-    }
-    righe.write(29);
-    switch(colonne) {
-        case 31:
-            key = 13;
-            beep(0.0002,100);
-            break;//011111
-        case 47:
-            key = 14;
-            beep(0.0002,100);
-            break;//101111
-        case 55:
-            key = 15;
-            beep(0.0002,100);
-            break;//110111
-        case 59:
-            key = 16;
-            beep(0.0002,100);
-            break;//111011
-        case 61:
-            key = 17;
-            beep(0.0002,100);
-            break;//111101
-        case 62:
-            key = 18;
-            beep(0.0002,100);
-            break;//111110
-    }
-    righe.write(27);//11011
-    switch(colonne) {
-        case 31:
-            key = 19;
-            beep(0.0002,100);
-            break;//011111
-        case 47:
-            key = 20;
-            beep(0.0002,100);
-            break;//101111
-        case 55:
-            key = 21;
-            beep(0.0002,100);
-            break;//110111
-        case 59:
-            key = 22;
-            beep(0.0002,100);
-            break;//111011
-        case 61:
-            key = 23;
-            beep(0.0002,100);
-            break;//111101
-        case 62:
-            key = 24;
-            beep(0.0002,100);
-            break;//111110
-    }
-    righe.write(23);//10111
-    switch(colonne) {
-        case 31:
-            key = 25;
-            beep(0.0002,100);
-            break;//011111
-        case 47:
-            key = 26;
-            beep(0.0002,100);
-            break;//101111
-        case 55:
-            key = 27;
-            beep(0.0002,100);
-            break;//110111
-        case 59:
-            key = 28;
-            beep(0.0002,100);
-            break;//111011
-        case 61:
-            key = 29;
-            beep(0.0002,100);
-            break;//111101
-        case 62:
-            key = 30;
-            beep(0.0002,100);
-            break;//111110
-    }
-    righe.write(15);//01111
-    switch(colonne) {
-        case 31:
-            key = 31;
-            beep(0.0002,100);
-            break;//011111
-        case 47:
-            key = 32;
-            beep(0.0002,100);
-            break;//101111
-        case 55:
-        
-            key = 33;
-            beep(0.0002,100);
-            break;//110111
-        case 59:
-            key = 34;
-            beep(0.0002,100);
-            break;//111011
-        case 61:
-            key = 35;
-            beep(0.0002,100);
-            break;//111101
-        case 62:
-            key = 36;
-            beep(0.0002,100);
-            break;//111110
-    }
-    key=key+50;
-    return key;
-}
-
-
diff -r 0cd0c7fe0682 -r 780a0888c3f2 keypad.h
--- a/keypad.h	Sun Apr 06 04:10:57 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-char Keypad();
\ No newline at end of file
diff -r 0cd0c7fe0682 -r 780a0888c3f2 keypad/keypad.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keypad/keypad.cpp	Sat Apr 12 20:55:13 2014 +0000
@@ -0,0 +1,178 @@
+#include "mbed.h"
+#include "buzz.h"
+//#include "buzz.cpp"
+
+
+//#include "TextLCD.h"
+//extern void timer1(void);
+//extern void beep(float freq,int time);
+
+BusIn colonne(PTE2,PTE3,PTE4,PTA16,PTC0,PTC7);
+BusOut righe(PTA1,PTA2,PTB10,PTB9,PTB8);
+//TextLCD lcd(PTE5,PTE4,PTE3,PTE2,PTB11,PTB10);
+
+char Keypad(void)
+{
+    char key = 100;
+  //  righe.write(31);//11111
+  //  switch(colonne) {
+  //      case 31:
+  //          key = 1;
+  //          break;//011111
+  //      case 47:
+  //          key = 2;
+  //          break;//101111
+  //      case 55:
+  //          key = 3;
+  //          break;//110111
+  //      case 59:
+  //          key = 4;
+  //          break;//111011
+  //      case 61:
+  //          key = 5;
+  //          break;//111101
+  //      case 62:
+  //          key = 6;
+  //          break;//111110
+ //   }
+    righe.write(30);//11110
+    switch(colonne) {
+        case 31:
+            key = 7;
+            beep(0.0002,100);
+            break;//011111
+        case 47:
+            key = 8;
+            beep(0.0002,100);
+            break;//101111
+        case 55:
+            key = 9;
+            beep(0.0002,100);
+            break;//110111
+        case 59:
+            key = 10;
+            beep(0.0002,100);
+            break;//111011
+        case 61:
+            key = 11;
+            beep(0.0002,100);
+            break;//111101
+        case 62:
+            key = 12;
+            beep(0.0002,100);
+            break;//111110
+    }
+    righe.write(29);
+    switch(colonne) {
+        case 31:
+            key = 13;
+            beep(0.0002,100);
+            break;//011111
+        case 47:
+            key = 14;
+            beep(0.0002,100);
+            break;//101111
+        case 55:
+            key = 15;
+            beep(0.0002,100);
+            break;//110111
+        case 59:
+            key = 16;
+            beep(0.0002,100);
+            break;//111011
+        case 61:
+            key = 17;
+            beep(0.0002,100);
+            break;//111101
+        case 62:
+            key = 18;
+            beep(0.0002,100);
+            break;//111110
+    }
+    righe.write(27);//11011
+    switch(colonne) {
+        case 31:
+            key = 19;
+            beep(0.0002,100);
+            break;//011111
+        case 47:
+            key = 20;
+            beep(0.0002,100);
+            break;//101111
+        case 55:
+            key = 21;
+            beep(0.0002,100);
+            break;//110111
+        case 59:
+            key = 22;
+            beep(0.0002,100);
+            break;//111011
+        case 61:
+            key = 23;
+            beep(0.0002,100);
+            break;//111101
+        case 62:
+            key = 24;
+            beep(0.0002,100);
+            break;//111110
+    }
+    righe.write(23);//10111
+    switch(colonne) {
+        case 31:
+            key = 25;
+            beep(0.0002,100);
+            break;//011111
+        case 47:
+            key = 26;
+            beep(0.0002,100);
+            break;//101111
+        case 55:
+            key = 27;
+            beep(0.0002,100);
+            break;//110111
+        case 59:
+            key = 28;
+            beep(0.0002,100);
+            break;//111011
+        case 61:
+            key = 29;
+            beep(0.0002,100);
+            break;//111101
+        case 62:
+            key = 30;
+            beep(0.0002,100);
+            break;//111110
+    }
+    righe.write(15);//01111
+    switch(colonne) {
+        case 31:
+            key = 31;
+            beep(0.0002,100);
+            break;//011111
+        case 47:
+            key = 32;
+            beep(0.0002,100);
+            break;//101111
+        case 55:
+        
+            key = 33;
+            beep(0.0002,100);
+            break;//110111
+        case 59:
+            key = 34;
+            beep(0.0002,100);
+            break;//111011
+        case 61:
+            key = 35;
+            beep(0.0002,100);
+            break;//111101
+        case 62:
+            key = 36;
+            beep(0.0002,100);
+            break;//111110
+    }
+    key=key+50;
+    return key;
+}
+
+
diff -r 0cd0c7fe0682 -r 780a0888c3f2 keypad/keypad.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keypad/keypad.h	Sat Apr 12 20:55:13 2014 +0000
@@ -0,0 +1,1 @@
+char Keypad();
\ No newline at end of file
diff -r 0cd0c7fe0682 -r 780a0888c3f2 led.h
diff -r 0cd0c7fe0682 -r 780a0888c3f2 main.cpp
--- a/main.cpp	Sun Apr 06 04:10:57 2014 +0000
+++ b/main.cpp	Sat Apr 12 20:55:13 2014 +0000
@@ -5,12 +5,15 @@
 #include "buzz.h"
 #include "TextLCD.h"
 
-#include "esc.h"
+
+//#include "esc.h"
 //1 ESC esc1(PTC9);
 PwmOut led_blue(PTC9);
-TextLCD lcd(PTE29, PTE30, PTC1, PTD0, PTD5, PTA13, TextLCD::LCD20x2); // rs, e, d4-d7 ok
-Serial pc(PTE20,PTE21);
+TextLCD lcd(PTE29, PTE30, PTC1, PTD0, PTD5, PTA13, TextLCD::LCD20x2);   // rs, e, d4-d7 ok
+Serial pc(PTE22,PTE23);
 DigitalOut r0(PTD7);
+DigitalOut fan_in_peltier(PTC11);                                       // Peltier FAN inside  the camber
+DigitalOut fan_out_peltier(PTC10);                                      // Peltier FAN outside of the chamber
 Ticker timer1ms;
 unsigned int led_blue_pulsewidth;
 /*
@@ -29,7 +32,8 @@
 
 */
 int main(void)
-{
+{wait(2);
+    pc.printf("hello");
 
     /*
 
@@ -88,9 +92,9 @@
     /*1 esc1.setThrottle(10);
             esc1.pulse();
             wait_ms(20);  // 20ms is the default period of the ESC pwm */
-    led_blue.period_us(10000);
+    led_blue.period_us(1000);
 
-    timer1ms.attach(&timer1, 0.1); //interrupt attached function(timer) with interval (1 ms)
+    timer1ms.attach(&timer1, 0.001); //interrupt attached function(timer) with interval (1 ms)
     pc.baud( BAUDRATE0 );
     char key;
     // lcd.cls();
@@ -98,16 +102,17 @@
     lcd.locate(0,0);
     lcd.printf("Hello 123456");
     wait(5.0);
-    led_blue_pulsewidth=500;
+    led_blue_pulsewidth=50;
 
     while(1) {
-        led_blue.period_us(10000);
+
+        led_blue.period_us(1000);
         //led_blue.pulsewidth_us(led_blue_pulsewidth);
         //  lcd.cls();
         key = Keypad();
         lcd.cls();
         lcd.locate(0,1);
-        lcd.printf("%c",key);
+        lcd.printf("Temp is %2.1fC\n\r", key);
        // if ((led_blue_pulsewidth >= 0 )&&( led_blue_pulsewidth <= 10000)) {
             if (key==61) {
                 led_blue_pulsewidth=led_blue_pulsewidth+100;
@@ -118,6 +123,8 @@
                 led_blue.pulsewidth_us(led_blue_pulsewidth);
             };
      //   };
+if (key==61) {fan_in_peltier=0;fan_out_peltier=1;};
+if (key==58) {fan_out_peltier=0;fan_in_peltier=1;};
 
         //if (key!=NULL)
         //{}