// The TotalCross button:
btnR = new Button("R"); // Button instantiation
btnR.setBackColor(Color.RED); // Set background color (red)
btnR.addPressListener(new PressListener() { // Press event listener
public void controlPressed(ControlEvent controlEvent) {
sttR = 1 - sttR; // Invert pin state
pinR.setValue(sttR); // Set value (HIGH or LOW)
add(btnR, CENTER - 70, AFTER + 40); // To make horizontally aligned
// buttons in the 'RGB' sequence,
// take the center reference and
// decrease 70 to place the
// leftmost R. In the Y axis just
// take the reference of the
// previous component and add 40