![](/media/cache/profiles/f095cedd23b99f1696fc8caecbcf257e.jpg.50x50_q85.jpg)
DMX512 library test http://mbed.org/users/okini3939/notebook/dmx512
Diff: main.cpp
- Revision:
- 2:eeb225671cac
- Parent:
- 0:ac66b38a42e3
- Child:
- 3:f8a105b2daf3
diff -r 25b5d99157c4 -r eeb225671cac main.cpp --- a/main.cpp Sat May 07 16:23:07 2011 +0000 +++ b/main.cpp Sun May 08 14:50:41 2011 +0000 @@ -5,31 +5,28 @@ //DMX dmx(p13, p14); //DMX dmx(p28, p27); -DigitalOut myled(LED1); +AnalogIn adc(p15); +PwmOut led[] = {(LED1), (LED2), (LED3), (LED4)}; Serial pc(USBTX, USBRX); int main() { - int i, j; + int i, n; - j = 0; while(1) { - myled = 1; - wait(0.2); - myled = 0; - wait(0.2); + wait(0.1); + + n = adc.read_u16() >> 8; + dmx.put(0, n); - j = j + 10; - if (j >= 256) j = 0; - for (i = 0; i < DMX_SIZE; i ++) { - dmx.put(i, j); + pc.printf("tx: %d / ", n); + + pc.printf("rx: ", dmx.get(0)); + for (i = 0; i < 4; i ++) { + n = dmx.get(i); + led[i] = (float)n / 255.0; + pc.printf("%d ", n); } - pc.printf("tx: %d\r\n", j); - - pc.printf("rx: ", dmx.get(0)); - for (i = 0; i < 16; i ++) { - pc.printf("%d ", dmx.get(i)); - } pc.printf("\r\n"); } }