I’ve been trying to figure out why I can only send strings to my pic controller. When I try using the Uart receiveByte() method I only get a solid 2vdc signal. Below is some of the code I used to try and get this to work. The parallax USB oscilloscope has helped a ton, but I’m still stuck with this problem. Any help would be appreciated.
Thanks,
Brian
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
package mainclasses;
import stamp.core.*;
import Arobot.*;
public class Arobot2 extends VirtualPeripheral {
public static picnet motor = new picnet();
//public static picnet2 motor2 = new picnet2(); tried creating an object here first and also tried using a static method in picnet2 class
public static void main() {
char r = 'b';
int j = 0, cnt = 0;
motor.run();
while (true) {
cnt++;
if (r == 'A')
motor.stop();
if (r == 'b')
{
if (cnt == 5) { // cnt being used because I don't know how to instantly switch from transmit to receive after string is sent when Uart is background VP
j=picnet2.wildCard; // if I get rid of this line the controller will send the string to the pic
continue;
}
else
continue;
}
else {
motor.run();
r='b';
}
}
}
}
/////////////////////////////////////////////////////////////////////////////////////////
package Arobot;
import stamp.core.*;
public class picnet2 {
public static int wildCard = 0;
public static final int netPin = CPU.pin8;
public static Uart UartReceive = new Uart(Uart.dirReceive, netPin, Uart.dontInvert, Uart.speed2400, Uart.stop1);
public void showByte() {
wildCard=UartReceive.receiveByte();
}
}