Welcome to Hackster!
Hackster is a community dedicated to learning hardware, from beginner to pro. Join us, it's free!
Victory-Noah MoussokiTrey GermanOmar KhadimallyAli Soomar
Published

Energia Serial tutorial

In the lab we will use the buttons to show ASCII pictures in the serial monitor.

BeginnerProtip3,702
Energia Serial tutorial

Things used in this project

Story

Read more

Code

Serial Monitor Ascii Images

C/C++
//Sets the different button states to 0:
  int b1state = 0;
  int b2state = 0;
  int b3state = 0;
  //Defines the constant variable type char in order to display the ascii images:
  //64 in the bracket is the maximum number of characters on each line:
  //This number should be adjusted according to the ascii image that you want to use:
  //"image" is the name of the variable:
  const char image[][64]={
  //Each line should be separated with a comma and the characters in each line should be enclosed in quotation marks:
" "
," "
," "
," "
," "
," "
," "
," "
," "
," "
," "
," "
," "
," "
," "
," "
," "
," "
," "
," "
," "
," "
," "
};
//"image2" is the name of the variable:
const char image2[][300]={
" /$$   /$$ /$$$$$$$$ /$$       /$$        /$$$$$$ "
,"| $$  | $$| $$_____/| $$      | $$       /$$__  $$"
,"| $$  | $$| $$      | $$      | $$      | $$  \ $$"
,"| $$$$$$$$| $$$$$   | $$      | $$      | $$  | $$"
,"| $$__  $$| $$__/   | $$      | $$      | $$  | $$"
,"| $$  | $$| $$      | $$      | $$      | $$  | $$"
,"| $$  | $$| $$$$$$$$| $$$$$$$$| $$$$$$$$|  $$$$$$/"
,"|__/  |__/|________/|________/|________/ \______/ "
};
//"image3" is the name of the variable:
const char image3[][200]={
  "                    ..oo$00ooo..                    ..ooo00$oo.."
,"                .o$$$$$$$$$`                          `$$$$$$$$$o."
,"             .o$$$$$$$$$`             .   .              `$$$$$$$$$o."
,"           .o$$$$$$$$$$~             /$   $\              ~$$$$$$$$$$o."
,"         .{$$$$$$$$$$$.              $\___/$               .$$$$$$$$$$$}."
,"        o$$$$$$$$$$$$8              .$$$$$$$.               8$$$$$$$$$$$$o"
,"       $$$$$$$$$$$$$$$              $$$$$$$$$               $$$$$$$$$$$$$$$"
,"      o$$$$$$$$$$$$$$$.             o$$$$$$$o              .$$$$$$$$$$$$$$$o"
,"      $$$$$$$$$$$$$$$$$.           o{$$$$$$$}o            .$$$$$$$$$$$$$$$$$"
,"     ^$$$$$$$$$$$$$$$$$$.         J$$$$$$$$$$$L          .$$$$$$$$$$$$$$$$$$^"
,"     !$$$$$$$$$$$$$$$$$$$$oo..oo$$$$$$$$$$$$$$$$$oo..oo$$$$$$$$$$$$$$$$$$$$$!"
,"     {$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$}"
,"     6$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$?"
,"     `$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$`"
,"      o$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$o"
,"       $$$$$$$$$$$$$$;`~`^Y$$$7^``o$$$$$$$$$$$o``^Y$$$7^`~`;$$$$$$$$$$$$$$$"
,"       `$$$$$$$$$$$`       `$`    ``$$$$$$$$$`     `$`       `$$$$$$$$$$$$`"
,"        !$$$$$$$$$7         !       `$$$$$$$`       !         V$$$$$$$$$!"
,"         ^o$$$$$$!                   `$$$$$`                   !$$$$$$o^"
,"           ^$$$$$`                    $$$$$                    `$$$$$^"
,"             `o$$$`                   ^$$$`                   `$$$o`"
,"               ~$$$.                   $$$.                  .$$$~"
,"                 `$;.                  `$`                  .;$`"
,"                    `.                  !                  .`"
};
void setup()
{
  //First we must enable the use of the serial moitor by setting the baud rate:
  Serial.begin(9600);
  //Sets the pins as inputs:
  pinMode(60, INPUT_PULLUP);
  pinMode(58, INPUT_PULLUP);
  pinMode(59, INPUT_PULLUP);
  analogReadResolution(12);
}
void loop()
{
  //Declares the button states to each pin
  b1state = digitalRead(60);
  b2state = digitalRead(58);
  b3state = digitalRead(59);
 //Declares that if the button is pushed, then the first image will print:
 if (b2state == HIGH) 
 {
   for (int i = 0; i<23; i++){
  Serial.println(image[i]);
   }
   }
 else
 {
 }
   //Declares that if the button is pushed, then the second image will print: 
 if (b1state == HIGH) 
   {
   for (int i = 0; i<8; i++){
  Serial.println(image2[i]);
   }
   }
   else
 {
 }
   //Declares that if the button is pushed, then the third image will print: 
 if (b3state == HIGH) 
   {
     for (int i = 0; i<24; i++){
  Serial.println(image3[i]);
   }
   }
   else
 {
 }
}

Credits

Victory-Noah Moussoki
3 projects • 6 followers
18 year old future Automotive Mechanical Engineer. Math and science. In my free time i like to swim, play basketball, baseball, and football.
Contact
Trey German
10 projects • 33 followers
Freelance Engineer, hacker, sky junkie, programmer, designer. All projects are my own.
Contact
Omar Khadimally
2 projects • 6 followers
Contact
Ali Soomar
11 projects • 41 followers
Student at the University of Texas at Austin
Contact

Comments

Please log in or sign up to comment.