I'm using the lightblue bean, which is a small arduino with bluetooth.
Here's the code running on the LBB
I can tell it's reading the button, because the light turns blue.
I can connect to the LBB using the BLE example, read data gets a bunch of data but I don't see the "Pin changed: "... What do I need to do to get the android app to receive data from the LBB as it's sent, as opposed to polling it?
Here's the code running on the LBB
B4X:
bool lastState = 0;
bool ledstate = 0;
void setup() {
// Initialize serial communication
Serial.begin(57600);
// Set D0 to pullup mode
pinMode(0, INPUT_PULLUP);
}
void loop() {
bool newState = digitalRead(2);
if (lastState != newState) {
lastState = newState;
Serial.print("Pin changed: ");
Serial.println(newState);
}
if(lastState){
Bean.setLed(0,0,255);
} else {
if(ledstate){
Bean.setLed(255,0,0);
} else {
Bean.setLed(0,255,0);
}
ledstate = !ledstate;
}
// Sleep for a bit before checking the pins again
Bean.sleep(10);
}
I can tell it's reading the button, because the light turns blue.
I can connect to the LBB using the BLE example, read data gets a bunch of data but I don't see the "Pin changed: "... What do I need to do to get the android app to receive data from the LBB as it's sent, as opposed to polling it?