Lego NXT 2.0 Brick running NXC/NBC
// Text to sound.
string Message = "A"; //The message.
safecall inline void ProcessMessage()
{
int Incr = 0;
string Display;
string Overall;
if(StrLen(Message) < 40)
{
while(Incr <= StrLen(Message))
{
Display = SubStr(Message, Incr, 1);
TextOut(0, LCD_LINE3, Display);
switch(Display)
{
case "A":
PlayTone(200,300);
break;
case "B":
PlayTone(205,300);
break;
case "C":
PlayTone(210,300);
break;
case "D":
PlayTone(215,300);
break;
case "E":
PlayTone(220,300);
break;
case "F":
PlayTone(225,300);
break;
case "G":
PlayTone(230,300);
break;
case "H":
PlayTone(235,300);
break;
case "I":
PlayTone(240,300);
break;
case "J":
PlayTone(245,300);
break;
case "K":
PlayTone(250,300);
break;
case "L":
PlayTone(255,300);
break;
case "M":
PlayTone(260,300);
break;
case "N":
PlayTone(265,300);
break;
case "O":
PlayTone(270,300);
break;
case "P":
PlayTone(275,300);
break;
case "Q":
PlayTone(280,300);
break;
case "R":
PlayTone(285,300);
break;
case "S":
PlayTone(290,300);
break;
case "T":
PlayTone(295,300);
break;
case "U":
PlayTone(300,300);
break;
case "V":
PlayTone(305,300);
break;
case "W":
PlayTone(310,300);
break;
case "X":
PlayTone(315,300);
break;
case "Y":
PlayTone(320,300);
break;
case "Z":
PlayTone(325,300);
break;
case " ":
PlayTone(490,300);
break;
default:
PlayTone(400,300);
break;
}
if(Incr == StrLen(Message))
{
PlayTone(600,600);
TextOut(0, LCD_LINE3, "Finished.");
}
TextOut(0, LCD_LINE4, Message);
Wait(1000);
Incr = Incr + 1;
}
}
else
{
TextOut(0, LCD_LINE4, "Str too long.");
}
}
task main()
{
ProcessMessage();
Wait(5000);
}
My first mini program for the device. It uses none of the Lego sensors yet. But I plan on integrating them in other projects. Currently the code runs very fast. I also inserted pauses to stop it from running too fast.
Anyone else got a modded NXT brick?