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 #include "mbed.h" 00002 00003 DigitalOut led1(PTC5); 00004 00005 DigitalOut leds[5] = { PTE6, PTE5, PTE4 ,PTE3, PTE2 }; 00006 int power[5] = { 0, 25, 50, 75, 100 }; 00007 00008 DigitalOut m1(PTA5); 00009 PwmOut pwm1(PTA13); 00010 AnalogIn fb1(PTB2); 00011 00012 Serial pc(USBTX, USBRX); 00013 00014 void setMotor(int p) 00015 { 00016 pc.printf("Motor at %d%% power\n\r", p); 00017 pwm1.write(p); 00018 } 00019 00020 int main() 00021 { 00022 pc.printf("Starting Active System test...\n\r"); 00023 wait(0.5); 00024 pwm1.period(4.0f); 00025 00026 while (true) { 00027 pc.printf("---- Forward Test ----\n\r"); 00028 led1 = 1; 00029 m1 = 0; 00030 for ( int i = 0; i < 5; i++ ) { 00031 setMotor(power[i]); 00032 leds[i] = 1; 00033 printf("Current Reading: %f\n\r", fb1); 00034 wait(1); 00035 leds[i] = 0; 00036 } 00037 00038 pc.printf("---- Backwards Test ----\n\r"); 00039 led1 = 0; 00040 m1 = 1; 00041 for ( int i = 0; i < 5; i++ ) { 00042 setMotor(power[i]); 00043 leds[i] = 1; 00044 printf("Current Reading: %f\n\r", fb1); 00045 wait(1); 00046 leds[i] = 0; 00047 } 00048 } 00049 }
Generated on Wed Jul 27 2022 20:49:20 by
1.7.2