01 02 03 DropBOB Designs: Arduino GSM Expandable Vehicle Connection Project 04 05 15 16 19 20 21 22 23 24 25 26 27 28 31 32 33

Arduino GSM Expandable Vehicle Connection Project

34
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.


Labels: , , ,

35 36 37 38