Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
00001 //motor_test 00002 00003 #include "mbed.h" 00004 00005 DigitalOut rled(LED_RED); 00006 DigitalOut gled(LED_GREEN); 00007 DigitalOut bled(LED_BLUE); 00008 Serial pc(USBTX, USBRX); 00009 PwmOut motor(PTC9); 00010 00011 int s; 00012 BusOut motor1(PTA13,PTD5); 00013 00014 void drivecommand () { 00015 s = pc.getc(); 00016 pc.printf("%c",s); 00017 if(s=='1'){ 00018 motor1 = 3; 00019 float pwidth; 00020 motor.period_ms(10); 00021 motor.pulsewidth(pwidth); 00022 pc.printf("slow\n"); 00023 00024 motor1 = 1; 00025 00026 } 00027 else if(s=='2'){ 00028 motor1 = 3; 00029 float pwidth; 00030 motor.period_ms(20); 00031 motor.pulsewidth(pwidth); 00032 pc.printf("normal\n"); 00033 motor1 = 2; 00034 00035 } 00036 else if(s=='3'){ 00037 motor1 = 3; 00038 float pwidth; 00039 motor.period_ms(30); 00040 motor.pulsewidth(pwidth); 00041 pc.printf("fast\n"); 00042 motor1 = 1; 00043 00044 } 00045 else if(s=='5'){ 00046 pc.printf("stop\n"); 00047 motor1 = 3; 00048 } 00049 } 00050 int main() { 00051 pc.attach(drivecommand, Serial::RxIrq); 00052 pc.printf("HELLO WORLD\n"); 00053 while(1) { 00054 00055 } 00056 }
Generated on Tue Aug 9 2022 07:12:30 by
1.7.2