Casper Kroon
/
Lecture3_a2
Sending LED voltage to HIDScope
main.cpp
- Committer:
- CasperK
- Date:
- 2018-09-20
- Revision:
- 0:8e9d8bb7f3ce
- Child:
- 1:37b02778f7f3
- Child:
- 3:43bd04c205e6
File content as of revision 0:8e9d8bb7f3ce:
#include "mbed.h" #include "FastPWM.h" #include "HIDScope.h" HIDScope scope(2); PwmOut LED(D5); Ticker ticker; DigitalIn button(D3); AnalogIn potmeter(A5); volatile float x; volatile float y; volatile float x_prev; void ShowStuf() { scope.set(0,x); y = (x_prev + x)/2.0; // averaging filter scope.set(1, y); // store data in second element of scope memory x_prev = x; // Prepare for next round scope.send(); // send what's in scope memory to PC } int main() { LED.period(0.00001f); ticker.attach(&ShowStuf, 0.001); while (true) { LED.write(potmeter); y = potmeter; } }