ROBOTC.net forums
http://www.robotc.net/forums/

Hear PI with your NXT
http://www.robotc.net/forums/viewtopic.php?f=15&t=8478
Page 1 of 1

Author:  Sigtrygg [ Fri Apr 11, 2014 2:52 pm ]
Post subject:  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

Author:  Coder A [ Sat Apr 12, 2014 5:40 pm ]
Post subject:  Re: Hear PI with your NXT

Cool program. However, number[70] never plays due to the loop exiting when i = 69. Still, cool!

Author:  Sigtrygg [ Mon Apr 14, 2014 3:06 pm ]
Post subject:  Re: Hear PI with your NXT

Yes, you are right! Thank you! :P
I have changed the code.

Bye,

Sigtrygg

Author:  Coder A [ Mon Apr 14, 2014 4:27 pm ]
Post subject:  Re: Hear PI with your NXT

You're welcome.

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/