so, basically im using seeed nrf52840 connected to a button with the help of a breadboard.
#include <bluefruit.h>
// BLE Settings
const char* DEVICE_NAME = "SafetyPendant";
#define SERVICE_UUID "19B10000-E8F2-537E-4F6C-D104768A1214"
#define CHAR_UUID "19B10001-E8F2-537E-4F6C-D104768A1214"
BLEService safetyService(SERVICE_UUID);
BLECharacteristic emergencyChar(CHAR_UUID);
const int BUTTON_PIN = D2; // Button with 10KΩ resistor to GND
const int LED_PIN = LED_BUILTIN; // Built-in LED
bool lastButtonState = HIGH;
void setup() {
Serial.begin(115200);
pinMode(BUTTON_PIN, INPUT_PULLUP);
pinMode(LED_PIN, OUTPUT);
digitalWrite(LED_PIN, LOW);
// BLE Setup
Bluefruit.begin();
Bluefruit.setName(DEVICE_NAME);
safetyService.begin();
emergencyChar.setProperties(CHR_PROPS_NOTIFY);
emergencyChar.setPermission(SECMODE_OPEN, SECMODE_OPEN);
emergencyChar.setFixedLen(1);
emergencyChar.begin();
// Start advertising
Bluefruit.Advertising.addService(safetyService);
Bluefruit.Advertising.addName();
Bluefruit.Advertising.start(0);
Serial.println("Ready! Press the button to trigger alerts.");
}
void loop() {
bool currentState = digitalRead(BUTTON_PIN);
// Send alert on button press (with debounce and LED feedback)
if (currentState == LOW && lastButtonState == HIGH) {
uint8_t alert = 1;
digitalWrite(LED_PIN, HIGH); // Visual feedback
emergencyChar.notify(&alert, 1);
Serial.println("SOS signal sent!");
delay(100); // LED on for 100ms
digitalWrite(LED_PIN, LOW);
delay(300); // Debounce delay
}
lastButtonState = currentState;
}
this is the code im running on arduino ide to send bytes when the button is pressed.
and well, the button certainly works properly BUT the information from my arduino to the app is kinda not going as i want it to?
when i press the button, it SHOULD update the label, but unfortunately due some reason, it just doesnt. what do i do? help me out peeps:_(
Thanks in advance:3
can i send you the aia file personally here? im not really comfy sharing the whole app kinda if thats cool w you? and well as bad as unknown characterisitcs label looks, its a different label in and of itself, the label saying "the location is:" is the one that shoudve changed lol
okay so updates, after surfing a bit, i thought of adding the list to csv thingy and now im getting this error when i press the button.
it makes it at least clear that the mit application is indeed sending the information over but my app cant read the information due whatever reason, i have to find a way for the app to convert whatevers the arduino is sending and convert into something that the app can read
i understood all your corrections except for the last line. the whole app and the system itself is working perfectly when its like this(couldnt understand the select item 1 part because its working flawlessly even without it)
Now, for the last part, If the value i receive is 1, i want the app to PERFORM a function, be it anything(like something on the last image) but somehow the if statements ive made using the logic equal function, or the math equal function do not seem to work (as in this case, its not sending an sms at all.) please help me out with this one too
and well thank you for your patience and time abg, i really appreciate it
and well, it works now?
another update, like you said, i used the select item 1 instead of doing the csv conversion and well, im getting the 1 without the quotes and the system is functional too
both the ways, the code is running, the latter being better as its what i wanted
anyways, thank you once again for following me through my errors and helping me rectify it, i really appreciate it. you da best