BusOut Hello World
Fork of BusOut_HelloWorld by
Use
The BusOut interface can be used to create an artificial bus of pins out of any digital ins. The pins do not have to have sequential hardware addressing. This example program counts up from 0 to 15 or binary 0000 to 1111 . The effect of this is turning LED1-LED4 on or off according to the number going across the bus. The example code toggles LED's on / off, if a tricolor led is on the board then the led will change colors.
Integer | binary | LED On(1) / Off(0) |
---|---|---|
0 | 0000 | LED4=0 LED3=0 LED2=0 LED1=0 |
1 | 0001 | LED4=0 LED3=0 LED2=0 LED1=1 |
2 | 0010 | LED4=0 LED3=0 LED2=1 LED1=0 |
3 | 0011 | LED4=0 LED3=0 LED2=1 LED1=1 |
4 | 0100 | LED4=0 LED3=1 LED2=0 LED1=0 |
5 | 0101 | LED4=0 LED3=1 LED2=0 LED1=1 |
6 | 0110 | LED4=0 LED3=1 LED2=1 LED1=0 |
7 | 0111 | LED4=0 LED3=1 LED2=1 LED1=1 |
8 | 1000 | LED4=1 LED3=0 LED2=0 LED1=0 |
9 | 1001 | LED4=1 LED3=0 LED2=0 LED1=1 |
10 | 1010 | LED4=1 LED3=0 LED2=1 LED1=0 |
11 | 1011 | LED4=1 LED3=0 LED2=1 LED1=1 |
12 | 1100 | LED4=1 LED3=1 LED2=0 LED1=0 |
13 | 1101 | LED4=1 LED3=1 LED2=0 LED1=1 |
14 | 1110 | LED4=1 LED3=1 LED2=1 LED1=0 |
15 | 1111 | LED4=1 LED3=1 LED2=1 LED1=1 |
Note
When initializing a BusOut object you initialize pins in their bit order from right to left, be careful as the bit order is the reverse of the object initializing order.
// init object BusOut thingy(pin0,pin1,...,pin15) // use object thingy = (val15<<15 | ... | val1 <<1 | val0 <<0) ; // where valx corresponds to the value to be put onto pinx
API
API summary
Import librarymbed
History
"Update mbed-os"
2017-06-24, by sarahmarshy [Sat, 24 Jun 2017 18:44:55 -0500] rev 4
"Update mbed-os"
Ported mbed OS 2 to mbed OS 5
2017-01-19, by mab5449 [Thu, 19 Jan 2017 10:35:01 -0600] rev 3
Ported mbed OS 2 to mbed OS 5
Added license to main.c file.;
2015-03-27, by mbedAustin [Fri, 27 Mar 2015 20:13:06 +0000] rev 2
Added license to main.c file.;
updated libraries;
2014-09-20, by mbedAustin [Sat, 20 Sep 2014 23:03:03 +0000] rev 1
updated libraries;
Hello World for BusOut
2013-02-11, by mbed_official [Mon, 11 Feb 2013 17:29:01 +0000] rev 0
Hello World for BusOut