View unanswered posts | View active topics It is currently Tue Oct 21, 2014 4:55 am






Reply to topic  [ 4 posts ] 
Hear PI with your NXT 
Author Message
Rookie

Joined: Mon Apr 08, 2013 12:50 pm
Posts: 10
Post Hear PI with your NXT
Hello community!

Do you like to hear the number PI by your LEGO NXT?
Try this code:

Code:
//Sigtrygg 2014
//Here you can hear the first 70 units of PI by your LEGO NXT

task main()
{
   nVolume = 2;
   int number[71];
   number[0]=3;
   number[1]=1;
   number[2]=4;
   number[3]=1;
   number[4]=5;
   number[5]=9;
   number[6]=2;
   number[7]=6;
   number[8]=5;
   number[9]=3;
   number[10]=5;
   number[11]=8;
   number[12]=9;
   number[13]=7;
   number[14]=9;
   number[15]=3;
   number[16]=2;
   number[17]=3;
   number[18]=8;
   number[19]=4;
   number[20]=6;
   number[21]=2;
   number[22]=6;
   number[23]=4;
   number[24]=3;
   number[25]=3;
   number[26]=8;
   number[27]=3;
   number[28]=2;
   number[29]=7;
   number[30]=9;
   number[31]=5;
   number[32]=0;
   number[33]=2;
   number[34]=8;
   number[35]=8;
   number[36]=4;
   number[37]=1;
   number[38]=9;
   number[39]=7;
   number[40]=1;
   number[41]=6;
   number[42]=9;
   number[43]=3;
   number[44]=9;
   number[45]=9;
   number[46]=3;
   number[47]=7;
   number[48]=5;
   number[49]=1;
   number[50]=0;
   number[51]=5;
   number[52]=8;
   number[53]=5;
   number[54]=0;
   number[55]=9;
   number[56]=7;
   number[57]=4;
   number[58]=9;
   number[59]=4;
   number[60]=4;
   number[61]=5;
   number[62]=9;
   number[63]=2;
   number[64]=3;
   number[65]=0;
   number[66]=7;
   number[67]=8;
   number[68]=1;
   number[69]=6;
   number[70]=4;

   while(true)
   {
      for(int i = 0; i <= 70; i++)
      {

         PlayImmediateTone( number[i]*500, 12);  // play tone
         nxtDisplayCenteredBigTextLine(4, "%d",number[i]);
         while(bSoundActive)  // while a sound is actively playing:
         {

         }
      }
      wait1Msec(2000);
   }
}


By,

Sigtrygg


Last edited by Sigtrygg on Mon Apr 14, 2014 3:07 pm, edited 1 time in total.



Fri Apr 11, 2014 2:52 pm
Profile
Moderator
Moderator

Joined: Thu Jan 03, 2013 5:10 pm
Posts: 198
Location: The plateau north of the Ohio River Valley, also known as Cave Country.
Post Re: Hear PI with your NXT
Cool program. However, number[70] never plays due to the loop exiting when i = 69. Still, cool!

_________________
I'm not a robot! I'm british! ~ quote from an asparagus
I am not a robot! I am a unicorn! ~ quote from a robot


Sat Apr 12, 2014 5:40 pm
Profile
Rookie

Joined: Mon Apr 08, 2013 12:50 pm
Posts: 10
Post Re: Hear PI with your NXT
Yes, you are right! Thank you! :P
I have changed the code.

Bye,

Sigtrygg


Mon Apr 14, 2014 3:06 pm
Profile
Moderator
Moderator

Joined: Thu Jan 03, 2013 5:10 pm
Posts: 198
Location: The plateau north of the Ohio River Valley, also known as Cave Country.
Post Re: Hear PI with your NXT
You're welcome.

_________________
I'm not a robot! I'm british! ~ quote from an asparagus
I am not a robot! I am a unicorn! ~ quote from a robot


Mon Apr 14, 2014 4:27 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 4 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.