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
Fork of Dragonfly_DigitalOut_BusOut_Example by
main.cpp@1:dea224e5ad51, 2015-10-02 (annotated)
- Committer:
- mfiore
- Date:
- Fri Oct 02 17:04:49 2015 +0000
- Revision:
- 1:dea224e5ad51
- Parent:
- 0:2c71706c23d3
update for mDot
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| mfiore | 1:dea224e5ad51 | 1 | /** mDot DigitalOut and BusOut Example Program |
| mfiore | 0:2c71706c23d3 | 2 | * |
| mfiore | 0:2c71706c23d3 | 3 | * This program demonstrates how to write digital outputs using the |
| mfiore | 1:dea224e5ad51 | 4 | * MultiTech mDot and MultiTech UDK2 hardware. The only |
| mfiore | 0:2c71706c23d3 | 5 | * additional hardware required is LEDs. Connect the LEDs between the |
| mfiore | 0:2c71706c23d3 | 6 | * bus pins and ground. |
| mfiore | 0:2c71706c23d3 | 7 | * |
| mfiore | 0:2c71706c23d3 | 8 | * Pins are active low, so 0V = 0 and 5V/3.3V = 1. |
| mfiore | 0:2c71706c23d3 | 9 | * |
| mfiore | 1:dea224e5ad51 | 10 | * This program blinks the PA_0 (UDK2 D3) LED using a DigitalOut pin and writes |
| mfiore | 1:dea224e5ad51 | 11 | * to pins PA_4, PA_6, and PA_5 (UDK2 pins D10, D12, and D13) as a 3 pin bus. |
| mfiore | 0:2c71706c23d3 | 12 | */ |
| mfiore | 0:2c71706c23d3 | 13 | |
| mfiore | 0:2c71706c23d3 | 14 | #include "mbed.h" |
| mfiore | 0:2c71706c23d3 | 15 | |
| mfiore | 0:2c71706c23d3 | 16 | int main() { |
| mfiore | 1:dea224e5ad51 | 17 | // write digital pins PA_4, PA_6, and PA_5 as a 3 pin bus |
| mfiore | 0:2c71706c23d3 | 18 | // the first pin is the LSB of the bus, the last is the MSB |
| mfiore | 1:dea224e5ad51 | 19 | BusOut bus(PA_4, PA_6, PA_5); |
| mfiore | 1:dea224e5ad51 | 20 | // pin PA_0 is connected to the D3 LED |
| mfiore | 1:dea224e5ad51 | 21 | DigitalOut led(PA_0); |
| mfiore | 0:2c71706c23d3 | 22 | |
| mfiore | 0:2c71706c23d3 | 23 | int count = 0; |
| mfiore | 0:2c71706c23d3 | 24 | |
| mfiore | 0:2c71706c23d3 | 25 | while (true) { |
| mfiore | 0:2c71706c23d3 | 26 | printf("writing %d to bus\r\n", count); |
| mfiore | 0:2c71706c23d3 | 27 | bus = count++; |
| mfiore | 0:2c71706c23d3 | 28 | count %= 8; |
| mfiore | 0:2c71706c23d3 | 29 | |
| mfiore | 0:2c71706c23d3 | 30 | led = !led; |
| mfiore | 0:2c71706c23d3 | 31 | |
| mfiore | 0:2c71706c23d3 | 32 | wait_ms(500); |
| mfiore | 0:2c71706c23d3 | 33 | } |
| mfiore | 0:2c71706c23d3 | 34 | } |
