Building Intelligent Robots

Spring 2009

 

Using the touch screen buttons of the CBC Controller console

 

In order to use the touch screen buttons on the CBC controller, we can make use of the following library calls:

 

left_button()

right_button()

up_button()

down_button()

a_button()

b_button()

 

Note that these functions are all described in the KISS-C programmer manual under "CBC Library Function Descriptions".

 

There is also a function to return the value of the mechanical black button on the lower right side of the controller:

 

black_button()

 

Each of these functions will return an integer giving the *current* value of the touch screen buttons --- as in the *immediate current* value. So, while you are pressing a button, the value returned by the corresponding function is 1, but as soon as you quit touching the button, the value returned is 0.

 

In your Project #1, you are asked to write your program so that you can specify input at run-time. That is, you should be able to select circle, square, or route as well as the size of the circle or square by using only inputs at the CBC. You should NOT need to recompile your program to change these values.

 

There are different approaches to this, but I would suggest using a simple loop to capture monitor button presses until a "submit" button is pressed to move to the next question (or to start driving around). For instance, if you decide to use the "b" button to submit a response, then your loop might look something like:

 

while (b_button() != 0)

{

 /* select task based on other buttons pressed */

}

 

You could do a similar process setting the size of the shapes. (Hint: Pick an initial value within the range specified and use the buttons to increment or decrement.)

 

One issue you will run into is the fact that the program executes very fast --- much faster than you can press a button and quit pressing it. Think about how you might be able to handle this issue....