Basic Stamp to Javelin
R0y4L
Posts: 23
Hello everyone, so the summer is coming up, university is over; time for some Javelin. Yeah!
I've recently bought Javelin, so I can program in Java, however I cant seem to find a way hot to make my Javelin move my motors.
On BS2 I used to enter: SEROUT 8,396[noparse][[/noparse]"!1M110001"]
"8" = Pin Number, "396" = Baud rate
How could i do this in Java?
Would anyone be generous enough to help me out with his please.
Thanks
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Visit: www.vbnoobs.co.uk
I've recently bought Javelin, so I can program in Java, however I cant seem to find a way hot to make my Javelin move my motors.
On BS2 I used to enter: SEROUT 8,396[noparse][[/noparse]"!1M110001"]
"8" = Pin Number, "396" = Baud rate
How could i do this in Java?
Would anyone be generous enough to help me out with his please.
Thanks
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Visit: www.vbnoobs.co.uk
Comments
import stamp.core.*;
public class MotorTest {
· static Uart mc = new Uart(Uart.dirTransmit, CPU.pin0, Uart.dontInvert,Uart.speed9600,Uart.stop1);
· static void main() {
··· mc.sendString("!1M110001");
··· while (true) ;
· }
}
Select the actual pin you use and check the BS2 manual what baudrate is represented by 396.
I assumed 9600 baud.
regards peter
few questions that pop into my head after seeing your reply are:
1. Can you explain the Uart declaration line. I am pretty sure its a variable declaration in Java but I dont understand how it works or what it means.
2. What is the reason of having a while() loop?
i have just looked at the BS2 manual and one page 419 I found that 396 is 2400 baud rate. Is there a difference if I enter 396 instead of 2400? Or Javelin wouldnt understand if i used 396?
Thanks
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Visit: www.vbnoobs.co.uk
static Uart mc = new Uart(Uart.dirTransmit, CPU.pin8, Uart.dontInvert,Uart.speed2400,Uart.stop1);
for same pin and baudrate as on your BS2.
The Uart declaration starts a serial transmit Virtual Peripheral that runs in the background.
Eg. characters are transmitted while your main code continues.
The while (true) ; is to keep the javelin alive.
Normally you would place all your code that must run in this main loop
(using method calls of course to keep your code readable).
regards peter
public class MotorTest {
public static void main() {
String value ="!1M1150100";
sendData(value);
}
public void sendData(String send){
Uart mc = new Uart(Uart.dirTransmit,CPU.pin8,Uart.dontInvert,Uart.speed2400,Uart.stop1);
mc.sendString(send);
while (true);
}
}
I have modified the whole code this time. However I get an error on line "sendData(value);" that the method "sendData" does not denote a class method. What this error means? im pretty sure that's how you pass a value to a method
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Visit: www.vbnoobs.co.uk
regards peter