TVZ Mechatronics Team / Mbed 2 deprecated MAB_Waveforms_B

Dependencies:   mbed

Committer:
tbjazic
Date:
Thu Dec 18 07:37:45 2014 +0000
Revision:
1:91e1f50eac98
Parent:
0:0713d899de2b
Cast operator (float) added for accurate division, and maximum number of points reduced to 50.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tbjazic 0:0713d899de2b 1 #include "mbed.h"
tbjazic 0:0713d899de2b 2
tbjazic 0:0713d899de2b 3 AnalogOut out(p18);
tbjazic 0:0713d899de2b 4 AnalogIn pot1(p19);
tbjazic 0:0713d899de2b 5
tbjazic 0:0713d899de2b 6 int main() {
tbjazic 0:0713d899de2b 7 int numberOfPoints;
tbjazic 0:0713d899de2b 8 while(1) {
tbjazic 1:91e1f50eac98 9 numberOfPoints = 10 + pot1 * 40; // 10 to 50 points
tbjazic 0:0713d899de2b 10 for (int i = 0; i < numberOfPoints; i++) {
tbjazic 1:91e1f50eac98 11 out = (float) i / numberOfPoints;
tbjazic 0:0713d899de2b 12 wait_us(10000/numberOfPoints);
tbjazic 0:0713d899de2b 13 }
tbjazic 0:0713d899de2b 14 }
tbjazic 0:0713d899de2b 15 }