Example of how use the Nucleo board with a processing GUI program. Processing code in the description section of mbed program.
main.cpp
- Committer:
- dreamworker
- Date:
- 2015-07-18
- Revision:
- 1:b89267dee6da
- Parent:
- 0:842c6c950cf5
- Child:
- 2:fb5b849eefa1
File content as of revision 1:b89267dee6da:
//Example of how use the Nucleo board with a processing GUI program // Nucleo program #include "mbed.h" PwmOut red(D10); PwmOut green(D11); PwmOut blue(D12); Serial Processing(USBTX, USBRX); float mapRed,mapGreen,mapBlue; char c; int val; float map(int value, float x_min, float x_max, float y_min, float y_max) { return (y_min + (((y_max - y_min)/(x_max - x_min)) * (value - x_min))); } int main(){ red = 1; wait(0.2); red = 0; green = 1; wait(0.2); green = 0; blue = 1; wait(0.2); blue = 0; Processing.baud(9600); while(1){ if (Processing.readable()==1){ c=Processing.getc(); if (c != 'E'){ if (c=='R'){ val = Processing.getc(); mapRed=map( val, 0, 255, 0, 1); red.write(mapRed);} else if ( c == 'G'){ val = Processing.getc(); mapGreen = map( val, 0, 255, 0, 1); green.write(mapGreen);} else if ( c == 'B'){ val = Processing.getc(); mapBlue = map( val, 0, 255, 0, 1); blue.write(mapBlue);} else {} } else {} } } }