Communication between two serial ports and control direction of motor through the serial terminal.
Dependencies: C12832_lcd mbed-rtos mbed
DebouncedIn.h@0:b8435cfc1bba, 2014-04-30 (annotated)
- Committer:
- bhakti08
- Date:
- Wed Apr 30 19:23:22 2014 +0000
- Revision:
- 0:b8435cfc1bba
The program does the following:; 1. Communication between two serial ports on the MBED; 2. Control ON/OFF of a LED(The pin can be used as direction control of the motor) using the joystick and the serial communication;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bhakti08 | 0:b8435cfc1bba | 1 | #include "mbed.h" |
bhakti08 | 0:b8435cfc1bba | 2 | |
bhakti08 | 0:b8435cfc1bba | 3 | class DebouncedIn { |
bhakti08 | 0:b8435cfc1bba | 4 | public: |
bhakti08 | 0:b8435cfc1bba | 5 | DebouncedIn(PinName in); |
bhakti08 | 0:b8435cfc1bba | 6 | |
bhakti08 | 0:b8435cfc1bba | 7 | int read (void); |
bhakti08 | 0:b8435cfc1bba | 8 | operator int(); |
bhakti08 | 0:b8435cfc1bba | 9 | |
bhakti08 | 0:b8435cfc1bba | 10 | int rising(void); |
bhakti08 | 0:b8435cfc1bba | 11 | int falling(void); |
bhakti08 | 0:b8435cfc1bba | 12 | int steady(void); |
bhakti08 | 0:b8435cfc1bba | 13 | |
bhakti08 | 0:b8435cfc1bba | 14 | private : |
bhakti08 | 0:b8435cfc1bba | 15 | // objects |
bhakti08 | 0:b8435cfc1bba | 16 | DigitalIn _in; |
bhakti08 | 0:b8435cfc1bba | 17 | Ticker _ticker; |
bhakti08 | 0:b8435cfc1bba | 18 | |
bhakti08 | 0:b8435cfc1bba | 19 | // function to take a sample, and update flags |
bhakti08 | 0:b8435cfc1bba | 20 | void _sample(void); |
bhakti08 | 0:b8435cfc1bba | 21 | |
bhakti08 | 0:b8435cfc1bba | 22 | // counters and flags |
bhakti08 | 0:b8435cfc1bba | 23 | int _samples; |
bhakti08 | 0:b8435cfc1bba | 24 | int _output; |
bhakti08 | 0:b8435cfc1bba | 25 | int _output_last; |
bhakti08 | 0:b8435cfc1bba | 26 | int _rising_flag; |
bhakti08 | 0:b8435cfc1bba | 27 | int _falling_flag; |
bhakti08 | 0:b8435cfc1bba | 28 | int _state_counter; |
bhakti08 | 0:b8435cfc1bba | 29 | |
bhakti08 | 0:b8435cfc1bba | 30 | }; |
bhakti08 | 0:b8435cfc1bba | 31 |