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: mbed
main.cpp
- Committer:
- mfiore
- Date:
- 2015-10-01
- Revision:
- 0:c7d463ff3deb
- Child:
- 1:5770646ab65b
File content as of revision 0:c7d463ff3deb:
/** Dragonfly DigitalIn, BusIn, and InterruptIn Example Program
*
* This program demonstrates how to read digital inputs using the
* MultiTech Dragonfly and MultiTech UDK2 hardware. The only
* additional hardware required is jumper wires.
*
* Pins are active low, so 0V = 0 and 5V/3.3V = 1.
*
* This program prints the new value of the BusIn each time it changes
* and the new value of the DigitalIn each time it changes.
*/
#include "mbed.h"
int main() {
// read digital pins D9 and D10 as a 2 pin bus
// the first pin is the LSB of the bus, the last is the MSB
BusIn bus(D9, D10);
// read digital pin D12
DigitalIn din(D12);
int old_bus = -1;
int old_din = -1;
while (true) {
if (bus != old_bus) {
old_bus = bus;
printf("bus = %d\r\n", old_bus);
}
if (din != old_din) {
old_din = din;
printf("din = %d\r\n", old_din);
}
wait_ms(100);
}
}