I am looking for an example to tap inputs of a SmartphoneApp, for example, after transmission of “on” the internal D7 to turn on.
I’ve found a library - GoBLE, but it’s more for joystick inputs than short texts.
I would like to make a comparison of Arduino and Photon - a serious commitment in a project is not planned.
Update:
In the meantime, I have tried the Lib GoBLE and realized that it is not compatible with the HM-10, but only with the Shield RoMeo from DFRobot.
Back to the simple things: the connection to the Bluetooth module is set up quickly and characters can be transmitted from the smartphone via a serial app.
int ledPin = D7; // The on-board LED
void setup() {
Serial.begin(9600); //initial the Serial
}
void loop() {
if (Serial.available()) {
char msg = Serial.read();
if (msg == '1') {
digitalWrite (ledPin, HIGH);
} else
if (msg == '2') {
digitalWrite (ledPin, LOW);
}
delay(2000);
}
}
For VC> 3V3, GND> GND, TXD> RXD, RXD> TXD I tried to switch the internal LED.
Nothing gets light. Does anyone have a hint?
Update 20.12.2018: Does anyone have an opportunity to explain why my photons are not reading anything on the Serial.Port and are not seeing any input from the smartphone’s Serial app at the rx / tx input?
// EXAMPLE USAGE with BLE Modul HM-10
// Wiring 3.3v<>3.3v - GND<>GND - TX<>RX - RX<>TX
int ledPin = D7; // The on-board LED
// https://docs.particle.io/reference/device-os/firmware/photon/#serial
void setup()
{
Serial.begin(9600); // open serial over USB
// On Windows it will be necessary to implement the following line:
// Make sure your Serial Terminal app is closed before powering your device
// Now open your Serial Terminal!
while(!Serial.isConnected()) Particle.process();
Serial1.begin(9600); // open serial over TX and RX pins
Serial.println("Hello Computer");
Serial1.println("Hello Serial 1");
}
void loop() {
if (Serial.available()) {
char msg = Serial.read();
Serial.println(msg);
if (msg == '1') {
digitalWrite (ledPin, HIGH);
Serial1.println("LED on");
} else
if (msg == '2') {
digitalWrite (ledPin, LOW);
Serial1.println("LED off");
}
}
}