Hello world for the TLC5940Servo library.
Dependencies: TLC5940Servo mbed
main.cpp@0:0b054b47ac3d, 2014-10-21 (annotated)
- Committer:
- dudanian
- Date:
- Tue Oct 21 02:36:27 2014 +0000
- Revision:
- 0:0b054b47ac3d
- Child:
- 1:aeb0ed70cbd0
Created.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dudanian | 0:0b054b47ac3d | 1 | #include "mbed.h" |
dudanian | 0:0b054b47ac3d | 2 | #include "TLC5940Servo.h" |
dudanian | 0:0b054b47ac3d | 3 | #include "Servo.h" |
dudanian | 0:0b054b47ac3d | 4 | |
dudanian | 0:0b054b47ac3d | 5 | TLC5940Servo tlc(p5, p7, p8, p9, p21); |
dudanian | 0:0b054b47ac3d | 6 | Servo serv(); |
dudanian | 0:0b054b47ac3d | 7 | |
dudanian | 0:0b054b47ac3d | 8 | |
dudanian | 0:0b054b47ac3d | 9 | |
dudanian | 0:0b054b47ac3d | 10 | int main() |
dudanian | 0:0b054b47ac3d | 11 | { |
dudanian | 0:0b054b47ac3d | 12 | // Enable the first LED |
dudanian | 0:0b054b47ac3d | 13 | tlc[5] = 0xFFF; |
dudanian | 0:0b054b47ac3d | 14 | int val = 0; |
dudanian | 0:0b054b47ac3d | 15 | int sw = 0; |
dudanian | 0:0b054b47ac3d | 16 | |
dudanian | 0:0b054b47ac3d | 17 | while (1) { |
dudanian | 0:0b054b47ac3d | 18 | switch (sw) { |
dudanian | 0:0b054b47ac3d | 19 | case 0: |
dudanian | 0:0b054b47ac3d | 20 | tlc[5] = 0x0fff; |
dudanian | 0:0b054b47ac3d | 21 | break; |
dudanian | 0:0b054b47ac3d | 22 | case 1: |
dudanian | 0:0b054b47ac3d | 23 | tlc[5] = 0x0f8f; |
dudanian | 0:0b054b47ac3d | 24 | break; |
dudanian | 0:0b054b47ac3d | 25 | case 2: |
dudanian | 0:0b054b47ac3d | 26 | tlc[5] = 0x0f0f; |
dudanian | 0:0b054b47ac3d | 27 | break; |
dudanian | 0:0b054b47ac3d | 28 | } |
dudanian | 0:0b054b47ac3d | 29 | sw = (sw + 1) % 3; |
dudanian | 0:0b054b47ac3d | 30 | printf("%d\n\r", tlc[5]); |
dudanian | 0:0b054b47ac3d | 31 | wait(1.0); |
dudanian | 0:0b054b47ac3d | 32 | } |
dudanian | 0:0b054b47ac3d | 33 | |
dudanian | 0:0b054b47ac3d | 34 | /*while(1) |
dudanian | 0:0b054b47ac3d | 35 | { |
dudanian | 0:0b054b47ac3d | 36 | if (sw){ |
dudanian | 0:0b054b47ac3d | 37 | tlc[5] = val++; |
dudanian | 0:0b054b47ac3d | 38 | if (val >= 0x0FFF) |
dudanian | 0:0b054b47ac3d | 39 | sw = 0; |
dudanian | 0:0b054b47ac3d | 40 | } |
dudanian | 0:0b054b47ac3d | 41 | else { |
dudanian | 0:0b054b47ac3d | 42 | tlc[5] = val--; |
dudanian | 0:0b054b47ac3d | 43 | if (val <= 0) |
dudanian | 0:0b054b47ac3d | 44 | sw = 1; |
dudanian | 0:0b054b47ac3d | 45 | } |
dudanian | 0:0b054b47ac3d | 46 | printf("%d\n\r", val); |
dudanian | 0:0b054b47ac3d | 47 | wait(0.01); |
dudanian | 0:0b054b47ac3d | 48 | }*/ |
dudanian | 0:0b054b47ac3d | 49 | |
dudanian | 0:0b054b47ac3d | 50 | |
dudanian | 0:0b054b47ac3d | 51 | } // write 203 307 409 for -40, 0, +40 degrees |