View unanswered posts | View active topics It is currently Sat Feb 06, 2016 5:18 am

 Page 1 of 1 [ 2 posts ]
 Print view Previous topic | Next topic
LCD Buttons
Author Message
Rookie

Joined: Thu Jul 08, 2010 3:50 pm
Posts: 18
LCD Buttons
I need some help with using the buttons on the LCD. I'm trying to switch between values inputted to the LCD. Any samples? The samples in RobotC don't go into button use and there's no help topic.

Sat Jul 10, 2010 8:16 am

Joined: Mon Jun 08, 2009 4:50 pm
Posts: 70
Re: LCD Buttons
Hi.

It's very simple, each button has a set value, and you can check the sum to see which are being pushed. 2 states (0 or 1) for 3 buttons = 2^3 = 8 possible combinations.

The LCD Buttons have values in powers of 2.
kLeftButton returns 1 (2^0)
kCenterButton returns 2 (2^1)
kRightButton returns 4 (2^2)

nLCDButtons returns the sum of the buttons when called. So it has these possible values 0 (none pushed) through 7 (all pushed).

here is a quick example, you can do more complex stuff with bit shifts and stuff, but this should show you the basic commands and how to use them. Download and run the code, and push the buttons and try to get the values 0 through 7 to show up. I hope it helps.

 Code:#pragma config(UART_Usage, UART2, VEX_2x16_LCD)//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*///**************************//* Possible combinations: *//*                        *//* Binary   Decimal   Btn *//**************************//* 000        0       --- *//* 001        1       L-- *//* 010        2       -C- *//* 011        3       LC- *//* 100        4       --R *//* 101        5       L-R *//* 110        6       -CR *//* 111        7       LCR *//**************************/task main(){    while(true)  {    // Clear LCD Lines    clearLCDLine(0);    clearLCDLine(1);        // Top LCD Line Display Stuff:    displayLCDPos(0,0);    displayNextLCDString("nLCDButtons = ");    displayNextLCDNumber(nLCDButtons);      // 'nLCDButtons' is the SUM of the LCD button values.             // Bottom LCD Line Display Stuff:    displayLCDPos(1,0);    displayNextLCDChar('L');    displayLCDPos(1,2);    displayNextLCDNumber(kLeftButton);      // 'kLeftButton' is worth decimal 1, binary 00000001, or 2^0.        displayLCDPos(1,6);    displayNextLCDChar('C');    displayLCDPos(1,8);    displayNextLCDNumber(kCenterButton);    // 'kCenterButton' is worth decimal 2, binary 00000010, or 2^1.        displayLCDPos(1,13);    displayNextLCDChar('R');    displayLCDPos(1,15);    displayNextLCDNumber(kRightButton);     // 'kRightButton' is worth decimal 4, binary 00000100, or 2^2.            // Wait a little to keep the screen refreshing smoothly:    wait1Msec(250);  }}

_________________
Bence Feher

ROBOTC - Testing/Documentation/Developer

Computer Science, Japanese, East Asian Studies
University of Pittsburgh, Konan University 甲南大学
Tue Jul 13, 2010 4:48 pm
Display posts from previous:  Sort by
 Page 1 of 1 [ 2 posts ]

#### Who is online

Users browsing this forum: No registered users and 1 guest

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

Search for:
 Jump to:  Select a forum ------------------ ROBOTC Applications    ROBOTC for LEGO MINDSTORMS       Third-party sensors    ROBOTC for CORTEX & PIC    ROBOTC for VEX IQ    ROBOTC for Arduino    Robot Virtual Worlds    Multi-Robot Communications    Issues and Bugs Competitions & Partners    Mini Urban Challenge    2014 Robotics Academy Summer of Learning    CS2N Robot Virtual Worlds Competitions       VEX Skyrise Competition 2014-2015       VEX Toss Up 2013-2014       FTC Block Party! 2013-2014    Competitions using VEX - BEST, TSA, VEX, and RoboFest!    FTC Programming    RoboCup Junior and Other ROBOT Competitions Virtual Brick Robotics Discussions    General Discussions    Project Discussions Off-Topic ROBOTC Forum & ROBOTC.net Suggestions/Feedback    ROBOTC Forums Suggestions/Comments    ROBOTC.net Suggestions/Comments       NXT Programming: Tips for Beginning with ROBOTC       VEX Programming: Tips for Beginning with ROBOTC    2013 Robotics Summer Of Learning       VEX Toss Up Programming Challenge       FTC Ring It Up! Programming Challenge    International Forums       Spanish Forums          ROBOTC for MINDSTORMS          ROBOTC for VEX       French Forums          ROBOTC pour Mindstorms          ROBOTC pour IFI VEX       Japanese Forums （日本語のフォーラム）       German Forums    2015 Spring Carnival Event    PLTW (Project Lead The Way)    Robotics Merit Badge