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
Diff: main.cpp
- Revision:
- 1:7198bf0747eb
- Parent:
- 0:8ee013fa99a5
--- a/main.cpp Tue Aug 27 19:09:49 2019 +0000
+++ b/main.cpp Thu Nov 21 20:21:34 2019 +0000
@@ -9,13 +9,14 @@
Serial bt(p28, p27);
-InterruptIn A (p21);
-DigitalIn B (p22);
+InterruptIn A (p29);
+DigitalIn B (p30);
Ticker END;
int rightCount = 0;
int lastCount = 0;
+int aux = 0;
void rightEncoderEvent (){
@@ -32,7 +33,7 @@
int realSpeed = (rightCount - lastCount);
lastCount = rightCount;
- bt.printf("\n\rCount: %d ## Speed: %d",rightCount,realSpeed);
+ //bt.printf("\n\rCount: %d ## Speed: %d",rightCount,realSpeed);
}
@@ -55,6 +56,8 @@
pwm.write(0.0f);
pwm1.write(0.0f);
+ bt.printf("Funcionando!");
+
while(1) {
if(bt.readable())
@@ -66,13 +69,21 @@
if (ch == 's') { dir = 1; dir1 = 1; pwm.write((0.2*speed)); pwm1.write((0.2*speed)); wait(0.02);}
if (ch == 'a') { dir = 0; dir1 = 1; pwm.write((0.2*speed)); pwm1.write((0.2*speed)); wait(0.02);}
if (ch == 'd') { dir = 1; dir1 = 0; pwm.write((0.2*speed)); pwm1.write((0.2*speed)); wait(0.02);}
- if (ch == 'r') {
- bt.printf("\n\rChose speed: ");
+ if (ch == 'g') {
+ //bt.printf("\n\rChose speed: ");
+ //bt.printf("Entrei no Go");
- while(bt.readable()) {}
- ch = bt.getc();
- speed = (int)ch - 48;
- bt.printf("\n\rActual speed: %d\n",speed);}
+ while(aux == 0) {
+ dir = 0; dir1 = 0; pwm.write(1); pwm1.write(1); wait (0.02);
+ ch = bt.getc();
+ if (ch == 'q') { bt.printf("Entrei no if pra sair do Go"); pwm.write(0); pwm1.write(0); aux = 1; }
+ }
+ bt.printf("Sai do while");
+ aux = 0;
+
+ }
+ //speed = (int)ch - 48;
+ //bt.printf("\n\rActual speed: %d\n",speed);}
//bt.printf("%c",ch);
@@ -104,4 +115,6 @@
wait(0.5);*/
}
+
+ //bt.printf("Sai do while");
}