MultiTech / Mbed 2 deprecated mDot_DigitalOut_BusOut_Example

Dependencies:   mbed

Fork of Dragonfly_DigitalOut_BusOut_Example by MultiTech

Committer:
mfiore
Date:
Thu Oct 01 20:43:30 2015 +0000
Revision:
0:2c71706c23d3
Child:
1:dea224e5ad51
initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mfiore 0:2c71706c23d3 1 /** Dragonfly DigitalOut and BusOut Example Program
mfiore 0:2c71706c23d3 2 *
mfiore 0:2c71706c23d3 3 * This program demonstrates how to write digital outputs using the
mfiore 0:2c71706c23d3 4 * MultiTech Dragonfly 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 0:2c71706c23d3 10 * This program blinks the D3 LED using a DigitalOut pin and writes
mfiore 0:2c71706c23d3 11 * to pins D9, D10, and D12 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 0:2c71706c23d3 17 // write digital pins D9, D10, and D12 as a 3 pin bus
mfiore 0:2c71706c23d3 18 // the first pin is the LSB of the bus, the last is the MSB
mfiore 0:2c71706c23d3 19 BusOut bus(D9, D10, D12);
mfiore 0:2c71706c23d3 20 // pin D3 is connected to the LED
mfiore 0:2c71706c23d3 21 DigitalOut led(D3);
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 }