![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Template project for University of York ELE00032C Lab 6
main.cpp
- Committer:
- ajp109
- Date:
- 2021-02-04
- Revision:
- 1:ec2d05bb8112
- Parent:
- 0:77209603a6fe
- Child:
- 2:3eacc92b984b
File content as of revision 1:ec2d05bb8112:
#include "mbed.h" DigitalOut dir1(D2); DigitalOut dir2(D3); PwmOut pwm(D4); void motor(float speed) { if (speed > 0) { dir1 = true; dir2 = false; pwm = speed; } else { dir1 = false; dir2 = true; pwm = -speed; } } int main() { while (true) { motor(1.0); thread_sleep_for(1000); motor(0.0); thread_sleep_for(1000); motor(-0.5); thread_sleep_for(1000); motor(0); thread_sleep_for(1000); } }