small change
Embed:
(wiki syntax)
Show/hide line numbers
main.cpp
00001 #include "mbed.h" 00002 00003 PwmOut motor_pwm(D5); 00004 DigitalOut dir(D4); 00005 00006 const int pwm_frequency = 10000; // PWM frequency 00007 bool direction = false; // Motor direction 00008 float duty_cycle = 0; 00009 int main() 00010 { 00011 dir.write(direction); // Write motor direction 00012 motor_pwm.period(1/pwm_frequency); // Motor PWM period 00013 motor_pwm.write(duty_cycle); // Set motor speed 00014 00015 while(true) { 00016 for(int i = 0; i<10; i++) { 00017 duty_cycle = 0.1*i; 00018 motor_pwm.write(duty_cycle); 00019 wait(0.2); 00020 } 00021 duty_cycle = 0; 00022 motor_pwm.write(duty_cycle); 00023 } 00024 } 00025 00026 00027 // kleine text van anne
Generated on Wed Jul 13 2022 01:10:36 by
1.7.2