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.
Dependencies: mbed
Revision 0:f22c817caf6c, committed 2019-08-10
- Comitter:
- NeoLewis
- Date:
- Sat Aug 10 18:15:12 2019 +0000
- Commit message:
- teste da versao funcional;
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
| mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Sat Aug 10 18:15:12 2019 +0000
@@ -0,0 +1,125 @@
+#include "mbed.h"
+//Serial pc(USBTX, USBRX);
+PwmOut Right(p23);
+PwmOut Left(p25);
+
+DigitalOut myled(LED1);
+#define MIN 1060 //990
+#define MAX 1860 //2040
+#define MID ((MAX+MIN)/2)
+int i;
+int k;
+
+/*
+int main() {
+
+ Right.period_ms(16);
+ Left.period_ms(16);
+ Right.pulsewidth_us(MID);
+ Left.pulsewidth_us(MID);
+ wait(2);
+
+ for (k=MAX,i=MID;k>=MIN,i<=MAX;k-=5,i+=5) //boa desaceleração
+ {
+ Left.pulsewidth_us(k);
+ wait(0.01);
+ Right.pulsewidth_us(i);
+ wait(0.01);
+ }
+}
+*/
+ /*
+ for (k=MAX;k>=MIN;k-=15) //bom numero para fazer curvas , desacelera rapido e reverte bem
+ {
+ Left.pulsewidth_us(k);
+ wait(0.01);
+ Right.pulsewidth_us(i);
+ wait(0.01);
+ }
+ */
+
+ /*
+ for (k;k>=MIN;k-=15) //TESTE PERFEITO
+ {
+ Left.pulsewidth_us(k);
+ wait(0.01);
+ Right.pulsewidth_us(i);
+ wait(0.01);
+ }
+
+
+
+
+ while(1) {
+ myled = !myled;
+ wait(1);
+ }
+}
+*/
+
+//Função que desloca os motores de acordo com o sinal PPM recebido
+void Drive(int maximo,int minimo,int controle)
+{
+ switch(controle)
+ {
+ case 1:
+ Right.period_ms(16);
+ Left.period_ms(16);
+ Left.pulsewidth_us(minimo);
+ Right.pulsewidth_us(minimo);
+ break;
+ case 2:
+ for (;k<=maximo || i<=maximo;k+=15,i+=15)
+ {
+ Left.pulsewidth_us(k);
+ wait(0.01);
+ Right.pulsewidth_us(i);
+ wait(0.01);
+ }
+ break;
+
+ case 3:
+ for (;k>=minimo || i<=maximo;k-=15,i+=15)
+ {
+ Left.pulsewidth_us(k);
+ wait(0.01);
+ Right.pulsewidth_us(i);
+ wait(0.01);
+ }
+ break;
+ case 4:
+ for (;k<=maximo || i>=minimo;k+=15,i-=15)
+ {
+ Left.pulsewidth_us(k);
+ wait(0.01);
+ Right.pulsewidth_us(i);
+ wait(0.01);
+ }
+ break;
+ case 5:
+ for (;k>=minimo || i>=minimo;k-=15,i-=15)
+ {
+ Left.pulsewidth_us(k);
+ wait(0.01);
+ Right.pulsewidth_us(i);
+ wait(0.01);
+ }
+ break;
+ default:
+ Left.pulsewidth_us(MID);
+ Right.pulsewidth_us(MID);
+ break;
+ }
+}
+
+int main()
+{
+ Drive(MAX,MIN,1);
+
+ while(1)
+ {
+ Drive(MAX,MIN,2);
+ }
+
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Sat Aug 10 18:15:12 2019 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file