ELCT-302 / Mbed 2 deprecated mbed_blinkyELCT302

Dependencies:   mbed

Committer:
jtho1327
Date:
Wed Jan 29 18:35:18 2020 +0000
Revision:
25:371af8d95c69
Parent:
24:7f14b70fc9ef
Child:
26:abb0cc9a1dd2
servo motion test

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dan 0:7dec7e9ac085 1 #include "mbed.h"
jtho1327 25:371af8d95c69 2 #include <iostream>
jtho1327 25:371af8d95c69 3 AnalogIn pot(PTB0);
jtho1327 25:371af8d95c69 4 PwmOut servo(PTE20);
dan 0:7dec7e9ac085 5
jtho1327 25:371af8d95c69 6 int main()
jtho1327 25:371af8d95c69 7 {
jtho1327 25:371af8d95c69 8 double val = 0;
jtho1327 25:371af8d95c69 9 servo.period(0.02);
jtho1327 25:371af8d95c69 10 while(1)
jtho1327 25:371af8d95c69 11 {
jtho1327 25:371af8d95c69 12 val = 0;
jtho1327 25:371af8d95c69 13 for(int i=0; i<200; i++){
jtho1327 25:371af8d95c69 14 wait(0.0001);
jtho1327 25:371af8d95c69 15 val = val + pot.read();
jtho1327 25:371af8d95c69 16 }
jtho1327 25:371af8d95c69 17 servo.pulsewidth(0.001+(val/200000));
jtho1327 25:371af8d95c69 18 cout << (val/200) << endl;
stevep 4:81cea7a352b0 19 }
dan 0:7dec7e9ac085 20 }