Arduino GSM Expandable Vehicle Connection Project


Working on some code today. I discovered the many awesome uses of switch(x){Case(0):} loops in the Arduino code. Here’s how they work:

if (buttons & BUTTON_UP) {                       // If a button is pressed and it is the Up button
          menu = menu – 1;                                 // Adjust the menu item to be the one before
          if (menu<0) menu=3;                            // If you went too far up, cycle through to the bottom
          switch(menu){                                      // Start the switch loop using the “menu” variable
            case 0:                                               // In case the menu = 0
              lcd.setCursor(0,1);                           // Place the LCD cursor at the bottom left
              lcd.print(“1-ChangeSensTrip”);         // Print “1-ChangeSensTrip” on the LCD
              break;                                              // Need this break, otherwise it will continue
            case 1:
              lcd.setCursor(0,1);
              lcd.print(“2)ShowSensorVals”);
              break;
          }
}

Here’s my code on Github if you would like to use it: https://github.com/Phoenix260/Capacitive_Sensor And don’t forget the licence agreement. Personal use only!

I’ll clean it up when I have time.

Enjoy.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s