Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
main.cpp@0:ab5b6bca3e25, 2017-11-06 (annotated)
- 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?
| User | Revision | Line number | New 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 | } |