L6230
Dependencies: L6230_BLDC mbed reScale
Revision 3:95a3a1fbc807, committed 2020-06-25
- Comitter:
- Marcelocostanzo
- Date:
- Thu Jun 25 17:52:14 2020 +0000
- Parent:
- 2:d42e168b0fa7
- Commit message:
- v4
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Thu Jun 25 17:44:28 2020 +0000 +++ b/main.cpp Thu Jun 25 17:52:14 2020 +0000 @@ -25,6 +25,8 @@ long speed; long adc; +bool start = 0; + int main() { pc.baud(115200); @@ -33,10 +35,29 @@ while(1) { - adc = pot.read() * 4096; - speed =_scale.from(adc); - //pc.printf("%i\r",speed); - motor.one_step(1, speed, &prevStep); + if((sw == 0) && (start == 0)) + { + start = 1; + wait(1); + } + + if((sw == 0) && (start == 1)) + { + start = 0; + wait(1); + } + + if(start == 1) + { + adc = pot.read() * 4096; + speed =_scale.from(adc); + //pc.printf("%i\r",speed); + motor.one_step(1, speed, &prevStep); + } + else + { + motor.stop(); + } } }