Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: Hotboards_keypad TextLCD mbed
Fork of Chronometer_V2 by
main.cpp
00001 //############################################################## 00002 //## 00003 //## Event: RoboVal - Robot Race 00004 //## 00005 //## Chronometer double use 00006 //## 00007 //## Version 1.99A 00008 //## 00009 //## Hardware platform used: ST NUCLEO-F401RE 00010 //## 00011 //## Software IDE used: mbed online version 00012 //## 00013 //## Organizzation: Verona FabLab 00014 //## 00015 //## Date creation: 2018.01.01 00016 //## 00017 //## Software developpers: FdF,GV, AG 00018 //## 00019 //## Base on original version of by FdF 00020 //## 00021 //############################################################## 00022 00023 #include <stdlib.h> 00024 #include "mbed.h" 00025 #include "TextLCD.h" 00026 #include "Hotboards_keypad.h" 00027 00028 00029 // Default Number Lap 00030 #define NUM_LAP 3 00031 00032 // Reference for Low/Min Voltage battery 00033 #define VBAT_MIN 7.2 00034 00035 // Defines the keys array with it's respective number of rows & cols, 00036 // and with the value of each key 00037 char keys[ 4 ][ 4 ] = 00038 { 00039 { '1' , '2' , '3' , 'A' }, 00040 { '4' , '5' , '6' , 'B' }, 00041 { '7' , '8' , '9' , 'C' }, 00042 { '*' , '0' , '#' , 'D' } 00043 }; 00044 00045 // Pin keypad 4x4 00046 // 1, 2, 3, 4, 5, 6, 7, 8 00047 // C4, C3, C2, C1, R4, R3, R2, R1 00048 // PB_0, PA_4 , PA_1 , PA_0, PA_13, PA_14, PC_14, PC_15 00049 // PC_15, PC_14, PA_14, PA_13, PA_0, PA_1, PA_4, PB_0 00050 // 00051 // Defines the pins connected to the rows 00052 DigitalInOut rowPins[ 4 ] = { PB_0 , PA_4 , PA_1 , PA_0 }; 00053 00054 // Defines the pins connected to the cols 00055 DigitalInOut colPins[ 4 ] = { PB_0 , PA_4 , PA_1 , PA_0 }; 00056 00057 // Creates a new keyboard with the values entered before 00058 Keypad kpd( makeKeymap( keys ) , rowPins , colPins , 4 , 4 ); 00059 00060 // Configures the serial port 00061 Serial pc( USBTX , USBRX ); 00062 00063 00064 00065 // read Voltage battery 00066 DigitalOut heartbeat(LED1); 00067 00068 // read Voltage battery, analog pin used PC_3 (Pin 37 of Morpho layout) 00069 //AnalogIn vbat(PC_3); 00070 00071 // User button pressure 00072 InterruptIn user_button(USER_BUTTON); 00073 00074 // Sensor connected to digital input D9, alias PC7 on Morpho layout 00075 // Now p29 and p31 00076 InterruptIn proximity(D9); 00077 00078 00079 // LCD Display (RS, E, D4, D5, D6, D7); 00080 TextLCD lcd(D2,D3,D4,D5,D6,D7); 00081 00082 00083 00084 00085 //------------------------------------------------------------ 00086 // 00087 // Main body 00088 // 00089 //------------------------------------------------------------ 00090 00091 int main() { 00092 00093 proximity.mode(PullDown); 00094 00095 00096 while(true) { 00097 00098 lcd.locate(0,0); 00099 lcd.printf("Character: "); 00100 00101 heartbeat = !heartbeat; 00102 00103 // Poll the keypad to look for any activation 00104 char key = kpd.getKey( ); 00105 00106 // If any key was pressed 00107 if( key ) 00108 { 00109 // Display the key pressed on serial port 00110 lcd.locate(0,1); 00111 lcd.printf( "%c" , key ); 00112 //lcd.printf( "\n\r" ); 00113 } 00114 } 00115 } 00116
Generated on Thu Jul 14 2022 19:48:49 by
1.7.2
