Ultrasonic Sensor

This is where you talk about the EV3 software itself, installation issues, and programming talk.

Moderators: roger, gloomyandy, skoehler

Ultrasonic Sensor

Postby Rkandana » Sat Nov 16, 2013 12:51 am

Hi, ever since NXT, whenever i used an ultrasonic sensor i always had it like this.

UltrasonicSensor S4 = new UltrasonicSensor(SensorPort.S4);

However when ever i run this i get an error saying:

Exception in thread "main" java.lang.NoSuchMethodError: lejos.nxt.UltrasonicSensor
.<int>(Llejos/nxt/SensorPort;)V
at Robot.<init>(Robot.java.7)
at EV3FirstProgram.main(EV3FirstProgram.java:6)

How can i fix this?

Thanks!
Rkandana
New User
 
Posts: 13
Joined: Sat Oct 19, 2013 1:15 pm

Re: Ultrasonic Sensor

Postby gloomyandy » Sat Nov 16, 2013 8:05 am

What are you compiling your program against? Git master or one of the tagged builds? See the sticky thread:
viewtopic.php?f=18&t=4782
for why you should probably be using the tagged 0.4.0-aplha sources for your programs. Also note that in the future things will be different between the NXT and EV3. You will have to change your code if you want it to run on the Ev3...
User avatar
gloomyandy
leJOS Team Member
 
Posts: 3881
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: Ultrasonic Sensor

Postby Rkandana » Sat Nov 16, 2013 2:14 pm

I am using the tagged sources. And yea i understand but i thought it was similar.

Thanks!
Rkandana
New User
 
Posts: 13
Joined: Sat Oct 19, 2013 1:15 pm

Re: Ultrasonic Sensor

Postby gloomyandy » Sat Nov 16, 2013 3:44 pm

If you are using the tagged sources then you should be getting an error when you try and compile that code. How are you trying to compile? Are you sure you are referencing the EV3 classes project (and not an NXT one?). With the tagged sources I'm pretty sure you will have to cast the SensorPort.S1 to something like EV3I2CPort for it to work...

Andy
User avatar
gloomyandy
leJOS Team Member
 
Posts: 3881
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK


Return to EV3 Software

Who is online

Users browsing this forum: No registered users and 2 guests

cron
more stuff