MSOE EE2905 / Mbed 2 deprecated MATLAB_controls_light

Dependencies:   mbed

Committer:
rossatmsoe
Date:
Mon Nov 06 01:09:21 2017 +0000
Revision:
0:ab5b6bca3e25
Child:
1:e9cb1aec787c
Demonstrates MATLAB sending control commands to Nucleo in real time.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
rossatmsoe 0:ab5b6bca3e25 1 #include "mbed.h"
rossatmsoe 0:ab5b6bca3e25 2 /* MATLAB can send data over to the Nucleo to control its operation or
rossatmsoe 0:ab5b6bca3e25 3 to output data via AnalogOut, etc. In this case, MATLAB sends a number and the
rossatmsoe 0:ab5b6bca3e25 4 onboard LED is set to blink that many times in 2 seconds.
rossatmsoe 0:ab5b6bca3e25 5 */
rossatmsoe 0:ab5b6bca3e25 6 PwmOut light(LED1);
rossatmsoe 0:ab5b6bca3e25 7 Serial matlab(USBTX,USBRX);
rossatmsoe 0:ab5b6bca3e25 8 int main() {
rossatmsoe 0:ab5b6bca3e25 9 int x;
rossatmsoe 0:ab5b6bca3e25 10 light=0.5; // turn on light
rossatmsoe 0:ab5b6bca3e25 11 while(1){
rossatmsoe 0:ab5b6bca3e25 12 matlab.scanf("%d",&x); // get number from MATLAB
rossatmsoe 0:ab5b6bca3e25 13 light.period(2.0/x); // set new period for blinking
rossatmsoe 0:ab5b6bca3e25 14 }
rossatmsoe 0:ab5b6bca3e25 15
rossatmsoe 0:ab5b6bca3e25 16 }