Hello there,
I have written a program with the purpose of hopefully controlling the directional flow and speed of a DC Motor from an input to be detected via a Wifly chip, which will be sent from another Wifly Chip.
The Wifly-Wifly Connections are configured however, with this program to control the Motors, some depressing results have be obtained.
Program :
#include "mbed.h"
#include "Wifly.h"
Serial pc(USBTX, USBRX);
Wifly wifly(p28,p27,p21, "mbed", "password", true);
PwmOut Pwm(p21);
DigitalOut fwd(p5);
DigitalOut rev(p7);
int main() {
char haha[129];
char var;
rev = fwd = 0;
Pwm.period(0.020);
Pwm.pulsewidth(0.11);
while (1) {
if (pc.readable()) {
wifly.putc(pc.getc());
printf("PC Readable\r\n");
}
else
{
pc.printf("PC Not Readable\r\n");
}
if (wifly.readable()) {
pc.printf("Wifly Connected!\r\n");
wifly.read(haha);
scanf("%s", &var);
switch (var) {
case 'f':
rev = 1;
fwd = 0;
break;
wait(0.5);
return(1);
case 'F':
Pwm.pulsewidth(0.5);
rev = 0;
fwd = 1;
break;
wait(0.5);
return(1);
case 'r':
rev = 1;
fwd = 0;
break;
wait(0.5);
return(1);
case 'R':
Pwm.pulsewidth(0.5);
rev = 1;
fwd = 0;
break;
wait(0.5);
return(1);
default:
break;
printf("Invalid Input\r\n");
wait(0.5);
return(1);
}
} else {
pc.printf("Wifly Not Connected!\r\n");
break;
wifly.reset();
}
}
}
//
The result I am picking up from Tera Term right now is simply
PC Not Connected
Wifly Not Connected !
I have no idea how to continue to work on this program, especially with the PC Not Connected Feedback that this program is sending me.
May I ask why is this happening / causes for this problem ?
Thank you for your time
Hello there,
I have written a program with the purpose of hopefully controlling the directional flow and speed of a DC Motor from an input to be detected via a Wifly chip, which will be sent from another Wifly Chip.
The Wifly-Wifly Connections are configured however, with this program to control the Motors, some depressing results have be obtained.
Program :
#include "mbed.h" #include "Wifly.h"
Serial pc(USBTX, USBRX); Wifly wifly(p28,p27,p21, "mbed", "password", true); PwmOut Pwm(p21); DigitalOut fwd(p5); DigitalOut rev(p7);
int main() { char haha[129]; char var; rev = fwd = 0; Pwm.period(0.020); Pwm.pulsewidth(0.11);
while (1) {
if (pc.readable()) { wifly.putc(pc.getc()); printf("PC Readable\r\n"); } else { pc.printf("PC Not Readable\r\n"); }
if (wifly.readable()) {
pc.printf("Wifly Connected!\r\n");
wifly.read(haha); scanf("%s", &var);
switch (var) { case 'f': rev = 1; fwd = 0; break; wait(0.5); return(1);
case 'F': Pwm.pulsewidth(0.5); rev = 0; fwd = 1; break; wait(0.5); return(1);
case 'r': rev = 1; fwd = 0; break; wait(0.5); return(1);
case 'R': Pwm.pulsewidth(0.5); rev = 1; fwd = 0; break; wait(0.5); return(1);
default: break; printf("Invalid Input\r\n"); wait(0.5); return(1); } } else { pc.printf("Wifly Not Connected!\r\n"); break; wifly.reset(); } } }
//
The result I am picking up from Tera Term right now is simply
PC Not Connected Wifly Not Connected !
I have no idea how to continue to work on this program, especially with the PC Not Connected Feedback that this program is sending me.
May I ask why is this happening / causes for this problem ?
Thank you for your time