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.
Revision 0:7db0d1b1daf0, committed 2012-11-07
- Comitter:
- hase
- Date:
- Wed Nov 07 09:35:47 2012 +0000
- Commit message:
- test pwm ng
Changed in this revision
diff -r 000000000000 -r 7db0d1b1daf0 USBDevice.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/USBDevice.lib Wed Nov 07 09:35:47 2012 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/hase/code/USBDevice/#9fdd29bb0d95
diff -r 000000000000 -r 7db0d1b1daf0 main.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Wed Nov 07 09:35:47 2012 +0000
@@ -0,0 +1,148 @@
+#include "mbed.h"
+#include <PwmOut.h>
+//#include "USBSerial.h"
+
+
+
+AnalogIn ana0(P0_11);
+AnalogIn ana1(P0_12);
+
+DigitalOut myled0(P1_31);
+DigitalOut myled1(P1_23);
+
+//DigitalOut po_0(P0_20);//3:
+//DigitalOut po_1(P0_18);//pwm0
+//DigitalOut po_1(p24);//pwm0
+//DigitalOut po_2(P1_15);
+DigitalOut po_3(P0_19);//pwm1
+//DigitalOut po_4(P1_24);//pwm2
+//DigitalOut po_5(P1_16);
+
+//DigitalOut po_6(P0_7);
+//DigitalOut po_7(P1_25);//pwm3
+DigitalOut po_8(P1_26);//pwm4
+DigitalOut po_9(P1_27);//pwm5
+//DigitalOut po_10(P0_8);//miso0
+DigitalOut po_11(P0_10);//mosi
+
+DigitalOut myled_R(P1_15);
+DigitalOut myled_G(P1_27);//0_8
+DigitalOut myled_B(P0_20);//0_20
+
+
+unsigned int Red;
+unsigned int Green;
+unsigned int Blue;
+unsigned int Motor;
+
+Ticker flipper;
+PwmOut motor2(P1_24);
+DigitalOut mr2(P1_16);
+
+PwmOut motor3(P1_25);
+DigitalOut mr3(P0_7);
+
+PwmOut motor4(P1_26);
+DigitalOut mr4(P0_8);
+
+DigitalOut mr6(P1_20);
+
+//PwmOut motor0(P0_18);
+//DigitalOut mr4(P0_8);
+
+//USBSerial serial;
+
+void flip() {
+ static int i;
+
+ myled0 = ~myled0;
+
+ if(i>Red)myled_R = 1;
+ else myled_R = 0;
+
+ if(i>Green)myled_G = 1;
+ else myled_G = 0;
+
+ if(i>Blue)myled_B = 1;
+ else myled_B = 0;
+
+
+
+
+ i++;
+ if(i>256){
+ i = 0;
+ }
+
+}
+
+int main() {
+ float Mot_Pot;
+ float Master;
+// PwmOut* motor0;
+
+ PwmOut motor0(P0_18);
+
+
+ LPC_IOCON->PIO0_18 &= ~0x07;
+ LPC_IOCON->PIO0_18 |= 0x02;
+ LPC_IOCON->PIO0_19 &= ~0x07;
+ LPC_IOCON->PIO0_19 |= 0x02;
+
+ flipper.attach(&flip, 0.00005); // the address of the function to be attached (flip) and the interval (2 seconds)
+// flipper2.attach(&flip2, 0.0005); // the address of the function to be attached (flip) and the interval (2 seconds)
+ // flipper.attach(&flip, 0.0001); // the address of the function to be attached (flip) and the interval (2 seconds)
+
+ motor0.period(0.002);
+// motor2.period(0.02);
+// motor3.period(0.02);
+// motor4.period(0.02);
+
+
+ Red = 0;
+ Green = 0;
+ Blue = 0;
+
+ myled0 = 0;
+
+ mr2 = 0;
+ mr3 = 0;
+ mr4 = 0;
+
+ LPC_IOCON->PIO1_20 &= ~0x07;
+ LPC_IOCON->PIO1_20 |= 0x00;
+
+ while(1) {
+
+ Mot_Pot = ana0;
+ Master = ana1;
+
+ Red = (int)(Master * 256);
+ Green = (int)(Master * 256);
+ Blue = (int)(Master * 256);
+
+ motor0.write(0.5);
+ motor2 = Master;
+ motor3 = Master;
+ motor4 = Master;
+
+ mr2 = 0;
+ mr3 = 0;
+ mr4 = 0;
+ mr6 = !mr6;
+/*
+ mr2 = !mr2;
+ mr3 = !mr3;
+ mr4 = !mr4;
+ mr6 = !mr6;
+
+ serial.puts("\x1b[3;1H");
+// serial.printf("Mot_Pot = %f \r\n",Mot_Pot);
+ serial.printf("Masetr = %f \r\n",Master);
+
+ serial.printf("Red = %d \r\n",Red);
+ serial.printf("Green = %d \r\n",Green);
+ serial.printf("Blue = %d \r\n",Blue);
+*/
+ }
+}
diff -r 000000000000 -r 7db0d1b1daf0 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed Nov 07 09:35:47 2012 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/e2ed12d17f06 \ No newline at end of file