To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.rcx.javaOpen lugnet.robotics.rcx.java in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / RCX / Java / 252
251  |  253
Subject: 
Re: Sound.playTone
Newsgroups: 
lugnet.robotics.rcx.java
Date: 
Thu, 22 May 2003 15:49:36 GMT
Viewed: 
4430 times
  
thanks Roger

I think if the sirene is kept working for long time, it starts to get
out of sync. Probably because the instructions in the for loop also
takes some time to execute.

I'm away from my rcx for many months and i don't remeber if i took this
conclusion teorically or be running the program for a long time and
listening...

Anyway usually we only need to use the sirene for seome seconds so there
is no problem.

daniel


This does not seem to be a problem with my code;
Motor.A.forward();
for (float x=0; x<1000; x+=0.1f) {
int sx = (int)(Math.sin(x)*100);//calculate sine once
Motor.A.setPower(3+3*sx/100);//avoid negative power
   Sound.playTone((int)(1000+sx),10);  //duration 100 ms
LCD.showNumber(1000+sx);//show tone
       try{Thread.sleep(100);}//wait the 100 ms
catch(InterruptedException e){};
}

The sound, light, and display are pretty much in synch.




Message is in Reply To:
  Re: Sound.playTone
 
Hi Daniel, (...) True (...) This does not seem to be a problem with my code; Motor.A.forward(); for (float x=0; x<1000; x+=0.1f) { int sx = (int)(Math.sin(x)*10.../calculate sine once Motor.A.setPower(3+3...0);//avoid negative power (...) (21 years ago, 21-May-03, to lugnet.robotics.rcx.java)

3 Messages in This Thread:

Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR