-
-
Hi Gordon,
how I can implement the NRF.on("connect") service to check, if there is a bluetooth device connected or not.
I just want to send signals from Puck to MDBT when they are connected.
I worked with a variable "connected" and set it to true or false.I have to setWatch functions with the Puck button for rising and falling. When I connect and disconnect it via the Puck button all is working.
But now I removed the battery from the MDBT and the Puck haven´t detected it as disconnected.
var log = print; var uart; var status = 0; var l; var t; var counter = 1; var connected = false; var kb = require("ble_hid_keyboard"); NRF.setServices(undefined, { hid : kb.report }); ///Mode Flashing setWatch(function(c) { if (connected == true) { setTimeout(function () { if (counter == 1){clearInterval(); digitalWrite (LED2, 1); uart.write("digitalWrite(LED2,1), digitalWrite(D19, 1);\n"); } if (counter == 2){clearInterval(); digitalWrite (LED2, 1); uart.write("digitalWrite(LED2,1), digitalWrite(D17, 1);\n"); } if (counter == 3){clearInterval(); digitalWrite (LED2, 1); uart.write("digitalWrite(LED2,1), digitalWrite(D15, 1);\n"); } if (counter == 4){clearInterval(); digitalWrite (LED2, 1); uart.write("digitalWrite(LED2,1), digitalWrite(D18, 1);\n"); } if (counter == 5){clearInterval(); digitalWrite (LED2, 1); uart.write("digitalWrite(LED2,1), digitalWrite(D16, 1);\n"); } if (counter == 6){clearInterval(); digitalWrite (LED2, 1); uart.write("digitalWrite(LED2,1), digitalWrite(D14, 1);\n"); } }, 1000); } }, BTN, { repeat: true, edge: 'rising' }); setWatch(function(c) { if (connected == false) { kb.tap(kb.KEY.ENTER, 0); } if (connected == true) { var l = c.time-c.lastTime; if ((c.time-c.lastTime > 0.3) && (c.time-c.lastTime < 1.0)) {counter = counter + 1;} if (counter > 6) {counter = 1;} log("Counter:"); log(counter); if (counter == 1) {clearInterval(); setInterval("{digitalPulse (LED2, 1, 50)}", 5000);} if (counter == 2) {clearInterval(); setInterval("{digitalPulse (LED2, 1, [50, 300, 50])}", 5000);} if (counter == 3) {clearInterval(); setInterval("{digitalPulse (LED2, 1, [50, 300, 50, 300, 50])}", 5000);} if (counter == 4) {clearInterval(); setInterval("{digitalPulse (LED2, 1, [50, 300, 50, 300, 50, 300, 50])}", 5000);} if (counter == 5) {clearInterval(); setInterval("{digitalPulse (LED2, 1, [50, 300, 50, 300, 50, 300, 50, 300, 50])}", 5000);} if (counter == 6) {clearInterval(); setInterval("{digitalPulse (LED2, 1, [50, 300, 50, 300, 50, 300, 50, 300, 50, 300, 50])}", 5000);} if (counter == 1){digitalWrite (LED2, 0); uart.write("digitalWrite(LED2,0), digitalWrite(D19, 0);\n"); } if (counter == 2){digitalWrite (LED2, 0); uart.write("digitalWrite(LED2,0), digitalWrite(D17,0);\n"); } if (counter == 3){digitalWrite (LED2, 0); uart.write("digitalWrite(LED2,0), digitalWrite(D15, 0);\n"); } if (counter == 4){digitalWrite (LED2, 0); uart.write("digitalWrite(LED2,0), digitalWrite(D18, 0);\n"); } if (counter == 5){digitalWrite (LED2, 0); uart.write("digitalWrite(LED2,0), digitalWrite(D16, 0);\n"); } if (counter == 6){digitalWrite (LED2, 0); uart.write("digitalWrite(LED2,0), digitalWrite(D14, 0);\n"); } } }, BTN, { repeat: true, edge: 'falling' }); //BLE Connect function flag(e) { var l = e.time-e.lastTime; if ((e.time-e.lastTime < 0.3) && (connected == false)){ log("Sending command"); log("Searching for device..."); NRF.requestDevice({ filters: [{ namePrefix: 'MDBT42Q' }] }).then(function(device) { log("Connecting..."); device.on('gattserverdisconnected', function() { }); return require("ble_uart").connect(device); }).then(function(u) { log("Connected"); digitalPulse(LED3, 1, 300); uart = u; connected = true; counter = 1; });} ///BLE Disconnect setTimeout(function(device) { if (connected == true){ uart.disconnect(); log("Disconnected"); connected = false; counter = 1; digitalPulse (LED3, 1, [50, 300, 50]); clearInterval(); } }, 60000); if ((e.time - e.lastTime < 0.3) && (connected == true) ){ setTimeout(function(device) { uart.disconnect(); log("Disconnected"); connected = false; if (connected == false){ clearInterval(); digitalPulse (LED3, 1, [50, 300, 50]); digitalWrite(D14, 0); ...
Best regards
-
Hi Gordon,
thank you very much for you help. I will test it.
Yes exactly I posted a video with a eating device.
Maybe I need to come back to you regarding the CE-Certification I have to do for medical devices.
I don´t know the requirements yet but I think I have to give information also to the basic product as I buy it about quality management, single parts on the pcb, material etc.I know its a tired topic but the Medical Device Regulation is very seriously :(
Best regards
-
Hi Gordon,
thanks for the update.
I wanted to ask again, if it possible to use Puck.js and the MDBT42Q for a commercial project?
Few month ago I started to develope a solution for disabled people, using Puck.js and the MDBT-Module (modified with an output PCB with Jack plugs), to switch multiple devices with one button. On top a cellphone application + speech recognition.And my second question is how to implement a mini smd buzzer like this:
https://www.sancobuzzer.com/smd-buzzer/57404424.htmlI soldered one between D11 and GND on Puck.js and found your awesome tutorial to make sound + music with Espruino.
I hear a sound but very quiet and not useful. What I want to do is to give an acoustic feedback next to the LED when the user presses the Puck.Best regards
-
-
-
-
Hi Gordon,
the program works great. I use also a force sensing resistor, I want to buit into the Puck.js.
The only thing is that I need to modify the program because when I remove the Battery from the Puck I get no more connection to the MDBT42Q. When I remove the power from the MDBT42Q it reconnects again.The the outputs (Jack connectors), I designed a PCB with the same size of the MDBT42Q and I will connect it like a sandwich furthermore with another PCB (same size) with the same battery + socket from the Puck as power supply.
If this works it would be a great product. Regarding CE-Certification on Puck and MDBT42Q its much easier to certify as a medical product because of these references.
It could be a great benefit for many users to have a wireless button.
Thank you again for the informations.
Best regards
-
-
-
Hi,
I am new in programming via Javascript. I have a Puck.JS and a MDBT42Q and I wanna do a connection with Bluetooth and the following function:
If both devices powered up they should connect to each other automatically. Then the simple function, when I do a click with the Puck I will switch a digital output to high and turn on the led for maybe 0,5sec at MDBT42Q and on the Puck.
Is there also a possibility to detect double clicks?I tried the tutorial with the servo/flag but the pairing starts when I push the button right? Thats why there is a delay for the incoming signal on the MDBT42Q.
Can you help me? I am a person for learning by doing but I got not forward here.
Greetings
-
-
-
Hi Gordon,
thank you very much for your suggestion. You are right, this make sense. I think I will do it with a MBDT42Q Breakout Board. I would connect it to my specific PCB with the Jack output and to place the needed transistor on that is no problem as well. The only thing I want to create is a receiver module as small as possible.
What I need to check is, if the tactile button is easy to press or if not that I could change this maybe. The thing is, the project would be for people with muscular deseases or tetraplegics who use a electric power wheelchair. To reduce the cable management there would be a great benefit.
Best regards
-
Hi Gordon,
first of all, thank you for your great support and your time!
This help a lot.I would like to develope a wireless button. So I could use the Puck.JS as finished product and I have to develope then the receiver module with the Bluno Beetle inside, which controls the outputs to other end devices via Jack connectors (3,5mm). The Jack connectors are common in the sector I would like to use it. The incoming 3,3V Signal from the external devices (3,5 Jack cabel) will be switched by a NPN-bipolar Transistor by the Bluno Beetle in the receiver module.
Best regards
-
Hi,
is it possible to make a bluetooth connection to the Bluno Beetle Module (ATMega328P, Bluetooth Chip: CC2540)?
I want to transmit three single signals of the button from Puck.JS (Single Click, Double Click and Hold Down). I saw too late there is also a breakout board from espruino (MBDT42). I ordered now a Bluno Beetle for Prototyping.
My second question if the Puck.JS has CE conformity and is it EMS-proofed?
Best regards
Cool, that works. Around 30 Seconds but thats ok for me!
Thanks Gordon!