Hi, ich bin gerade dabei, eine Bluetooth-Verbindung zwischen 2 Arduinos mittels 2 Bluetooth-Modulen (https://www.sparkfun.com/products/10393) herzustellen. Es konnte bereits eine Verbindung hergestellt werden, aber nur wenn man diese selber mit dem dem Befehl "C,<MAC-Adresse>" eingibt. kann mir jemand sagen, wie ich es schaffen kann, dass diese Verbindung automatisch hergestellt wird? Es wurde an beiden Arduinos folgender Code verwendet. #include <SoftwareSerial.h> int bluetoothTx = 2; // TX-O pin of bluetooth mate, Arduino D2 int bluetoothRx = 3; // RX-I pin of bluetooth mate, Arduino D3 SoftwareSerial bluetooth(bluetoothTx, bluetoothRx); void setup() { Serial.begin(9600); // Begin the serial monitor at 9600bps bluetooth.begin(115200); // The Bluetooth Mate defaults to 115200bps //delay(320); // IMPORTANT DELAY! (Minimum ~276ms) bluetooth.print("$$$"); // Enter command mode delay(15); // IMPORTANT DELAY! (Minimum ~10ms) bluetooth.println("U,9600,N"); // Temporarily Change the baudrate to 9600, no parity bluetooth.begin(9600); // Start bluetooth serial at 9600 } void loop() { if(bluetooth.available()) // If the bluetooth sent any characters { // Send any characters the bluetooth prints to the serial monitor Serial.print(bluetooth.read()); } if(Serial.available()) // If stuff was typed in the serial monitor { // Send any characters the Serial monitor prints to the bluetooth bluetooth.print((int)Serial.read()); } // and loop forever and ever! }
Poste doch bitte mal den GANZEN CODE INKL. MAIN FUNKTION! gertrud hiller schrieb: > //delay(320); // IMPORTANT DELAY! (Minimum ~276ms) Was soll sowas? Ist es jetzt IMPORTANT oder nicht? Falls nein: Dann steht da sinnloses Zeugs. Falls ja: Warum ist es dann auskommentiert?
das ist der komplette code :D ja das mit dem important bin ich mir selbst nicht ganz im klaren ob man das benötigt, das habe ich bei einem tutorial gesehen ;)
gertrud hiller schrieb: > kann mir jemand sagen, wie ich es schaffen kann, dass diese Verbindung > automatisch hergestellt wird? Sollte es nicht deine Arbeit sein? Copypastecode um eine Zeile zu erweitern sollte echt nicht zu viel verlangt sein. Johannes O. schrieb: > Poste doch bitte mal den GANZEN CODE INKL. MAIN FUNKTION! Gibt es bei Arduino so nicht, das ist der ganze Code. Sie wird ersetzt durch setup() und loop().
vn nn schrieb: > Johannes O. schrieb: >> Poste doch bitte mal den GANZEN CODE INKL. MAIN FUNKTION! > > Gibt es bei Arduino so nicht, das ist der ganze Code. Sie wird ersetzt > durch setup() und loop(). Danke für den Hinweis... Das Arduino Zeugs scheint ja unglaublich verhunzt zu sein... gertrud hiller schrieb: > bluetooth.println("U,9600,N"); Hier übergibst du ja dem Bluetooth Module irgendeinen Befehl bzgl. Baudrate. Setze so eine zusätzliche Zeile ins setup(). Aber eben nicht mit U,96usw. sondern mit dem Befehl zum Verbinden. Dann sollte es wohl klappen. Oder wo besteht genau die Schwierigkeit?
genau das habe ich ja versucht! aber es funktioniert nicht. und das rot LED blinkt sehr schnell wenn man im command-mode ist und längsämer wenn man im normalen-modus ist. und auch wenn man den Befehl "Serial.println("---")" für das verlassen des command-modes eingibt,blinkt das LED weiterhin schnell. deshalb wollte ich fragen was man da machen kann?
Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.