Shop OBEX P1 Docs P2 Docs Learn Events
trying to use the equivalent code of serout in java stamp — Parallax Forums

trying to use the equivalent code of serout in java stamp

brianLbrianL Posts: 8
edited 2008-09-01 14:11 in General Discussion
Hello,

I recently got the javelin stamp and am trying to make my robot move, but am unsure how to do it.· I need to send a signal to a pic controller from pin 8.· Using the basic stamp II controller I would use the serout command as so: serout net,baud,[noparse][[/noparse]"!1M11600F0"] 'Forward,speed=3,distance 10'.
net con 8· // coprocessor network pin,·baud con 396· // coprocessor·network baud rate,
Can anyone show me some code that would be the equivalent of this.

Thanks,
Brian

Comments

  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2008-09-01 03:33
    This should do it.

    import stamp.core.*;
    
     
    public class picnet {
     
      static final int netPin = CPU.pin8;
     
      static Uart picUart = new Uart(Uart.dirTransmit,netPin,Uart.dontInvert,Uart.speed9600,Uart.stop1);
    
     
      static String picCode = new String("!1M11600F0"); //string to send to pic
     
      static void main() {
        int i;
        System.out.println("picnet demo");
        for (i=0; i<picCode.length(); i++) {
          picUart.sendByte(picCode.charAt(i));
        }
        while (true) {
          //keep javelin alive
        }
      }
     
    }
    
    

    Save the code as picnet.java
    Check the baudrate.

    regards peter
  • brianLbrianL Posts: 8
    edited 2008-09-01 14:11
    My debug screen is saying i out of scope.· I'm playing with the code you sent me and I think i'll be able to figure it out.· Thanks, for pointing me in the right direction.



    thanks,

    Brian
Sign In or Register to comment.