Example : button array

Example :  button array



 
Arduino Code

// AppGosu  for smart phone

#include "AppGosu.h"
AppGosu app;


void setup() {     
  
  app.start();
  app.setDelayCmd(20);  // max speed 20ms

  myStart(); 
}

void loop() {

 
} // end of loop

//---------------------------------------------------------
void serialEvent() {
      app.serialMessage();
      EventLoop();
}
void EventLoop() {
    if( app.btConnected()) {   // for auto starting
        myStart();
    }
   
    // user event code here
    app.textSize(30);
    for(int i=1; i<8; i++) {
        if( app.eventButton(i)) {
            app.background(0,0,0);
            app.text("button clicked  : " + (String)i, 200, 50+100*i);
        }
    }

}
//---------------------------------------------------------
void myStart(void) {
    // user starting code here
    app.clearAll();
    app.background(0,0,0);
    app.textSize(50);
    app.fill(255,255,255);
    app.text("--- button ---", 60, 50);
   
    // button
    for(int i=1; i<8; i++) {
      app.button("btn "+(String)i, 10, 100*i, 150, 80, i);
    }

}









No comments: