Useless Serial.monitor projects

Hi all! I've decided to post most of the useless projects I've been doing
recently out of boredom. Some of them start off as short codes that end
up being made bigger and bigger so are terribly written and could be
much better. First up, a clock/timer:

int hours = 0;
int minutes = 0;
int seconds = 0;
void timerend();
int incomingbyte;

void setup(){
  Serial.begin(115200);
  Serial.println("To end timer enter 'e'");
}

void loop(){
  seconds++;
  if(seconds == 60){
    seconds = 0;
    minutes ++;
  }
  if(minutes == 60){
    minutes = 0;
    hours ++;
  }
  if(hours == 12){
    hours = 0;
  }
  Serial.print("Hours:");
  Serial.println(hours);
  Serial.print("Minutes:");
  Serial.println(minutes);
  Serial.print("Seconds:");
  Serial.println(seconds);
  Serial.println();
  delay(1000);
  if(Serial.available() > 0){
    incomingbyte = Serial.read();
    if(incomingbyte == 'e')
      void timerend();
   }
}

void timerend(){
  loopforever:
  goto loopforever;
}

Next up, an encrypter:

/*
Change words[] into encrypting phrase,
change n into number of symbols in it +1
*/
char words [80] = "Chris is a lovely brother.";
char encryptkey = 2;
// char strlen (words[]);

void setup(){
  int i;
  int n = 80;
  Serial.begin(9600);
  
  Serial.print("Initial words:  ");
  Serial.println(words);
  

for(int i = 0; i < n ; i++){
  words[i] = words[i] ^ encryptkey;
}

encryptkey = encryptkey++;
Serial.print("Initial encryption:  ");
Serial.println(words);

for(int i = 0; i < n ; i++){
words[i] = words[i] ^ encryptkey;
}
Serial.print("Second encryption:  ");
Serial.println(words);

for(int i = 0; i < n ; i++){
  words[i] = words[i] ^ encryptkey;
}
Serial.print("Initial encryption:  ");

encryptkey = encryptkey--;
for(int i = 0; i < n ; i++){
  words[i] = words[i] ^ encryptkey;
}
  
  Serial.print("Un-encrypted words:  ");
  Serial.println(words);

}
void loop(){
}

// char strlen(words[]){
//  int count;
//  while(words[]){
//    count++
//  }

Then a double encrypter:

/*
Change words[] into encrypting phrase,
change n into number of symbols in it +1
*/
char words [80] = "Chris is a lovely brother.";
char encryptkey = 2;
// char strlen (words[]);

void setup(){
  int i;
  int n = 80;
  Serial.begin(9600);
  
  Serial.print("Initial words:  ");
  Serial.println(words);
  

for(int i = 0; i < n ; i++){
  words[i] = words[i] ^ encryptkey;
}

encryptkey = encryptkey++;
Serial.print("Initial encryption:  ");
Serial.println(words);

for(int i = 0; i < n ; i++){
words[i] = words[i] ^ encryptkey;
}
Serial.print("Second encryption:  ");
Serial.println(words);

for(int i = 0; i < n ; i++){
  words[i] = words[i] ^ encryptkey;
}
Serial.print("Initial decryption:  ");
Serial.println(words);
encryptkey = encryptkey--;
u
for(int i = 0; i < n ; i++){
  words[i] = words[i] ^ encryptkey;
}
  
  Serial.print("Un-encrypted words:  ");
  Serial.println(words);

}
void loop(){
}

// char strlen(words[]){
//  int count;
//  while(words[]){
//    count++
//  }

This one is simply aascii table with more scientific symbols:

void setup() 
{ 
  Serial.begin(9600); 
  Serial.println("ASCII Table ~ Character Map"); 
} 
int thisByte = 33; 
void loop() 
{ 
  Serial.print(thisByte, BYTE);    
  Serial.print(", dec: "); 
  Serial.print(thisByte);   
  Serial.print(", hex: "); 
  Serial.print(thisByte, HEX);     

  Serial.print(", oct: "); 
  Serial.print(thisByte, OCT);     

  Serial.print(", bin: "); 
  Serial.println(thisByte, BIN);   
  if(thisByte == 255) {    
    while(true) { 
      continue; 
    } 
  } 
  thisByte++;  
}

This is a very simple one used to compute the hypoteneuse of a rightangled triangle:

void pythag(int Long, int Short);  //pythag prototype
void setup()
{
  Serial.begin(9600);
  pythag(4, 8);       //call pythag
}

void loop()
{
}

//My pythagoras function:
void pythag(int Long, int Short)
{  
  float hyp;
  hyp = (sqrt((Long*Long)+(Short*Short)));
  Serial.print("Hypoteneuse = ");
  Serial.println(hyp);
}

This one generates lots of random stuff:

int incomingByte;  
long randNumber;
long randLetter1;
long randLetter2;
long randLetter3;
long randLetter4;
long randLetter5;
void setup() {
  Serial.begin(9600);
  randomSeed(analogRead(0));
  Serial.println("To create a random letter type in 'l' or 'c' for lower or capitals.");
  Serial.println("To create a random number type in n.");
  Serial.println("To create a random character type in r."); 
  Serial.println("To create a random symbol (ie. not a letter or number) type s.");
  Serial.println("To create a random word type in 'w'.");
  Serial.println("Type 'b' for a blank line");
  Serial.println("To go to a random function type 'g'.");
  Serial.println();
}
void loop() {
  if (Serial.available() > 0) {
    incomingByte = Serial.read();
    if (incomingByte == 'l') 
    {
    loop1:
    randNumber = random(97, 122);
    Serial.print("l:");
    Serial.println(randNumber, BYTE);
    }
    else if (incomingByte == 'c')
    {
    loop2:
    randNumber = random(65, 90);
    Serial.print("c:");
    Serial.println(randNumber, BYTE);
    }
    else if (incomingByte == 'n')
    {
    loop3:
    randNumber = random(100);
    Serial.print("n:");
    Serial.println(randNumber);
    }
    else if (incomingByte == 'r')
    {
    loop4:
    randNumber = random(33, 255);
    Serial.print("r:");
    Serial.println(randNumber, BYTE);
    }
    else if (incomingByte == 's')
    {
    loop5:
    randNumber = random(0,1);
    if(randNumber == 0){
    Serial.print("s:  ");
    randNumber = random(33, 47);
    Serial.println(randNumber, BYTE);
    }
    else {
    loop6:
    Serial.print("s:");
    randNumber = random(123, 191);
    Serial.println(randNumber, BYTE);
    }
    }
    else if (incomingByte == 'b')
    {
    Serial.println();
    }
     else if (incomingByte == 'w')
    {
    loop7:
    randLetter1 = random(65, 90);
    randLetter2 = random(97, 122);
    randLetter3 = random(97, 122);
    randLetter4 = random(97, 122);
    randLetter5 = random(97, 122);
    Serial.print("n:");
    Serial.print(randLetter1, BYTE);
    Serial.print(randLetter2, BYTE);
    Serial.print(randLetter3, BYTE);
    Serial.print(randLetter4, BYTE);
    Serial.print(randLetter5, BYTE);
    Serial.println();
    }
    else if (incomingByte, 'g'){
    randNumber = random(1,7);
    Serial.print("g:  ");
    if (randNumber == 1) goto loop1;
    else if (randNumber == 2) goto loop2;
    else if (randNumber == 3) goto loop3;
    else if (randNumber == 4) goto loop4;
    else if (randNumber == 5) goto loop5;
    else if (randNumber == 6) goto loop6;
    else goto loop7;
    }
    else
    {
    Serial.println("Please type one of the stated letters.");
    }
  }
}

There are more, but they are too long to fit in the code thing (???).

For extra credit, combine them all into one program, with a menu option to choose which to run.

There are more, but they are too long to fit in the code thing (???).

Try http://code.google.com/projecthosting/

-transfinite