![](/media/cache/profiles/f095cedd23b99f1696fc8caecbcf257e.jpg.50x50_q85.jpg)
DMX512 library test http://mbed.org/users/okini3939/notebook/dmx512
main.cpp@2:eeb225671cac, 2011-05-08 (annotated)
- Committer:
- okini3939
- Date:
- Sun May 08 14:50:41 2011 +0000
- Revision:
- 2:eeb225671cac
- Parent:
- 0:ac66b38a42e3
- Child:
- 3:f8a105b2daf3
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
okini3939 | 0:ac66b38a42e3 | 1 | #include "mbed.h" |
okini3939 | 0:ac66b38a42e3 | 2 | #include "DMX.h" |
okini3939 | 0:ac66b38a42e3 | 3 | |
okini3939 | 0:ac66b38a42e3 | 4 | DMX dmx(p9, p10); |
okini3939 | 0:ac66b38a42e3 | 5 | //DMX dmx(p13, p14); |
okini3939 | 0:ac66b38a42e3 | 6 | //DMX dmx(p28, p27); |
okini3939 | 0:ac66b38a42e3 | 7 | |
okini3939 | 2:eeb225671cac | 8 | AnalogIn adc(p15); |
okini3939 | 2:eeb225671cac | 9 | PwmOut led[] = {(LED1), (LED2), (LED3), (LED4)}; |
okini3939 | 0:ac66b38a42e3 | 10 | Serial pc(USBTX, USBRX); |
okini3939 | 0:ac66b38a42e3 | 11 | |
okini3939 | 0:ac66b38a42e3 | 12 | int main() { |
okini3939 | 2:eeb225671cac | 13 | int i, n; |
okini3939 | 0:ac66b38a42e3 | 14 | |
okini3939 | 0:ac66b38a42e3 | 15 | while(1) { |
okini3939 | 2:eeb225671cac | 16 | wait(0.1); |
okini3939 | 2:eeb225671cac | 17 | |
okini3939 | 2:eeb225671cac | 18 | n = adc.read_u16() >> 8; |
okini3939 | 2:eeb225671cac | 19 | dmx.put(0, n); |
okini3939 | 0:ac66b38a42e3 | 20 | |
okini3939 | 2:eeb225671cac | 21 | pc.printf("tx: %d / ", n); |
okini3939 | 2:eeb225671cac | 22 | |
okini3939 | 2:eeb225671cac | 23 | pc.printf("rx: ", dmx.get(0)); |
okini3939 | 2:eeb225671cac | 24 | for (i = 0; i < 4; i ++) { |
okini3939 | 2:eeb225671cac | 25 | n = dmx.get(i); |
okini3939 | 2:eeb225671cac | 26 | led[i] = (float)n / 255.0; |
okini3939 | 2:eeb225671cac | 27 | pc.printf("%d ", n); |
okini3939 | 0:ac66b38a42e3 | 28 | } |
okini3939 | 0:ac66b38a42e3 | 29 | |
okini3939 | 0:ac66b38a42e3 | 30 | pc.printf("\r\n"); |
okini3939 | 0:ac66b38a42e3 | 31 | } |
okini3939 | 0:ac66b38a42e3 | 32 | } |