Node-red colour picker serially
Dependencies: mbed node-red_serial_parse
main.cpp@0:f6084e072350, 2017-03-30 (annotated)
- Committer:
- rushabkarani
- Date:
- Thu Mar 30 12:38:15 2017 +0000
- Revision:
- 0:f6084e072350
Node -red serial color picker
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
rushabkarani | 0:f6084e072350 | 1 | #include "mbed.h" |
rushabkarani | 0:f6084e072350 | 2 | |
rushabkarani | 0:f6084e072350 | 3 | #include "node_red_parse.h" |
rushabkarani | 0:f6084e072350 | 4 | |
rushabkarani | 0:f6084e072350 | 5 | PwmOut red(LED1); // pwmout pin defination for red led |
rushabkarani | 0:f6084e072350 | 6 | PwmOut green(LED2); // pwmout pin defination for green led |
rushabkarani | 0:f6084e072350 | 7 | PwmOut blue(LED3); // pwmout pin defination for blue led |
rushabkarani | 0:f6084e072350 | 8 | Serial pc(USBTX,USBRX); //serial pin defination |
rushabkarani | 0:f6084e072350 | 9 | |
rushabkarani | 0:f6084e072350 | 10 | |
rushabkarani | 0:f6084e072350 | 11 | float* led1; |
rushabkarani | 0:f6084e072350 | 12 | int main() { |
rushabkarani | 0:f6084e072350 | 13 | //intially turning off all led |
rushabkarani | 0:f6084e072350 | 14 | red = 1; |
rushabkarani | 0:f6084e072350 | 15 | green = 1; |
rushabkarani | 0:f6084e072350 | 16 | blue = 1; |
rushabkarani | 0:f6084e072350 | 17 | |
rushabkarani | 0:f6084e072350 | 18 | char buffer[25]; |
rushabkarani | 0:f6084e072350 | 19 | while(1) { |
rushabkarani | 0:f6084e072350 | 20 | if(pc.readable()) |
rushabkarani | 0:f6084e072350 | 21 | { |
rushabkarani | 0:f6084e072350 | 22 | pc.scanf("%s",&buffer); |
rushabkarani | 0:f6084e072350 | 23 | pc.printf("I got %s\n\r", buffer); |
rushabkarani | 0:f6084e072350 | 24 | |
rushabkarani | 0:f6084e072350 | 25 | led1=stringparsing(buffer); |
rushabkarani | 0:f6084e072350 | 26 | red = led1[0]; |
rushabkarani | 0:f6084e072350 | 27 | green = led1[1]; |
rushabkarani | 0:f6084e072350 | 28 | blue = led1[2]; |
rushabkarani | 0:f6084e072350 | 29 | } |
rushabkarani | 0:f6084e072350 | 30 | |
rushabkarani | 0:f6084e072350 | 31 | } |
rushabkarani | 0:f6084e072350 | 32 | } |
rushabkarani | 0:f6084e072350 | 33 | |
rushabkarani | 0:f6084e072350 | 34 | |
rushabkarani | 0:f6084e072350 | 35 |