<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">hallo gemeinde,<div><br></div><div>ich baue gerade an einem projekt, in dem zwei arduinos miteinander kommunizieren sollen. der eine, am ort des geschehens, erfasst daten und schaltet schalter, der andere ist remote, er erhält die daten und befielt, was der andere tun soll - per zweidrahtleitung. </div><div><br></div><div>weil urumständlich, immer die zweidrahtleitung abstecken zum sketch-upload, und damit man sehen kann, was passiert, arbeite ich mit der SoftwareSerial-Library, wo andere pins zur kommunikation genutzt werden können als pin0 und pin1 </div><div><br></div><div>ich habe alles abgesteckt um nur die kommunikation in den griff zu bekommen, zwei ganz einfache patches - aber es funktioniert nicht.</div><div><br></div><div>das empfänger-borad empfängt mal nix, mal ein und dann auch mal zwei bytes, und immer unfug. </div><div>mit mySerial.print genauso wie mySerial.write,</div><div>mit wie ohne Serial Monitor, </div><div>9600baud genauso wie mit 2400baud, </div><div>zweidrahtleitung: 18cm </div><div><br></div><div>was ist mein problem?</div><div>verzweifelt sich christoph</div><div><br></div><div><br></div><div><br></div><div><br></div><div>der Serial Monitor sagt:</div><font class="Apple-style-span" face="Helvetica"><span class="Apple-style-span" style="font-size: 12px;"><div><font class="Apple-style-span" face="Helvetica"><span class="Apple-style-span" style="font-size: 12px;"><br></span></font></div><br>I receive: ˙<br>I receive: ˙<br>I receive: õ<br>I receive: A<br>I receive: <br>I receive: ķ<br>I receive: ]<br>I receive: Ī<br>I receive: ˙<br>I receive: W<br>I receive: A<br>I receive: ß<br>I receive: ˙<br>I receive: Á<br>I receive: <br>I receive: ˙<br>I receive: ũ<br>I receive: A<br>I receive: ß<br>I receive: ˙<br>I receive: A<br>I receive: ī<br>I receive: ˙<br><br></span></font><div> </div><div><br></div><div>ein board sendet alle 2sec ein "A"</div><div><br></div><div><div><font class="Apple-style-span" face="Monaco" style="font-size: 12px;">#include <SoftwareSerial.h></font></div><div><font class="Apple-style-span" face="Monaco" style="font-size: 12px;"><br></font></div><div><font class="Apple-style-span" face="Monaco" style="font-size: 12px;">SoftwareSerial mySerial(6, 7);</font></div><div><font class="Apple-style-span" face="Monaco" style="font-size: 12px;"><br></font></div><div><font class="Apple-style-span" face="Monaco" style="font-size: 12px;">void setup() </font></div><div><font class="Apple-style-span" face="Monaco" style="font-size: 12px;">{</font></div><div><font class="Apple-style-span" face="Monaco" style="font-size: 12px;"> pinMode(13, OUTPUT);</font></div><div><font class="Apple-style-span" face="Monaco" style="font-size: 12px;"><br></font></div><div><font class="Apple-style-span" face="Monaco" style="font-size: 12px;"> Serial.begin(9600);</font></div><div><font class="Apple-style-span" face="Monaco" style="font-size: 12px;"> mySerial.begin(9600);</font></div><div><font class="Apple-style-span" face="Monaco" style="font-size: 12px;">}</font></div><div><font class="Apple-style-span" face="Monaco" style="font-size: 12px;"><br></font></div><div><font class="Apple-style-span" face="Monaco" style="font-size: 12px;">void loop() // run over and over</font></div><div><font class="Apple-style-span" face="Monaco" style="font-size: 12px;">{</font></div><div><font class="Apple-style-span" face="Monaco" style="font-size: 12px;"> digitalWrite(13, HIGH);</font></div><div><font class="Apple-style-span" face="Monaco"><span class="Apple-style-span" style="font-size: 12px; "><br></span></font></div><div><font class="Apple-style-span" face="Monaco"><span class="Apple-style-span" style="font-size: 12px;"> // mySerial.print('A');<br> // mySerial.print("A");<br> mySerial.write(65);<br></span><br></font></div><div><font class="Apple-style-span" face="Monaco" style="font-size: 12px;"> delay(200);</font></div><div><font class="Apple-style-span" face="Monaco" style="font-size: 12px;"><br></font></div><div><font class="Apple-style-span" face="Monaco" style="font-size: 12px;"> digitalWrite(13, LOW);</font></div><div><font class="Apple-style-span" face="Monaco" style="font-size: 12px;"><br></font></div><div><font class="Apple-style-span" face="Monaco" style="font-size: 12px;"> delay(1800);</font></div><div><font class="Apple-style-span" face="Monaco" style="font-size: 12px;">}</font></div><div><br></div></div><div><br></div><div>das andere board zeigt an was es empfängt:</div><div><br></div><div><div><font class="Apple-style-span" face="Monaco"><span class="Apple-style-span" style="font-size: 12px;">#include <SoftwareSerial.h></span></font></div><font class="Apple-style-span" face="Monaco"><span class="Apple-style-span" style="font-size: 12px;"><br>SoftwareSerial mySerial(10, 11);<br><br>char myChar;<br><br>void setup() <br>{<br> pinMode(2, OUTPUT);<br> pinMode(3, OUTPUT);<br> pinMode(4, OUTPUT);<br> pinMode(5, OUTPUT);<br> pinMode(6, OUTPUT);<br> pinMode(7, OUTPUT);<br> pinMode(8, OUTPUT);<br> pinMode(9, OUTPUT);<br> <br> pinMode(13, OUTPUT);<br> <br><br> // Serial.begin(9600);<br><br> mySerial.begin(9600);<br> // mySerial.listen();<br>}<br><br>void loop()<br>{<br> if (mySerial.available()) {<br> myChar = mySerial.read();<br><br> // Serial.print("I receive: ");<br> // Serial.println(myChar);<br><br> digitalWrite(2, bitRead(myChar, 0));<br> digitalWrite(3, bitRead(myChar, 1));<br> digitalWrite(4, bitRead(myChar, 2));<br> digitalWrite(5, bitRead(myChar, 3));<br> digitalWrite(6, bitRead(myChar, 4));<br> digitalWrite(7, bitRead(myChar, 5));<br> digitalWrite(8, bitRead(myChar, 6));<br> digitalWrite(9, bitRead(myChar, 7));<br><br></span></font><span class="Apple-style-span" style="font-family: Monaco; font-size: 12px; "> digitalWrite(13, HIGH);</span><font class="Apple-style-span" face="Monaco"><span class="Apple-style-span" style="font-size: 12px;"><br> }<br> delay(200);<br><br> digitalWrite(2, LOW);<br> digitalWrite(3, LOW);<br> digitalWrite(4, LOW);<br> digitalWrite(5, LOW);<br> digitalWrite(6, LOW);<br> digitalWrite(7, LOW);<br> digitalWrite(8, LOW);<br> digitalWrite(9, LOW);<br><br></span></font><span class="Apple-style-span" style="font-family: Monaco; font-size: 12px; "> digitalWrite(13, LOW);</span><font class="Apple-style-span" face="Monaco"><span class="Apple-style-span" style="font-size: 12px; "><br></span></font><font class="Apple-style-span" face="Monaco"><span class="Apple-style-span" style="font-size: 12px;"><br></span></font></div><div><font class="Apple-style-span" face="Monaco"><span class="Apple-style-span" style="font-size: 12px;"> delay(50);<br>}<br><br></span></font></div><div></div><div></div><div><font class="Apple-style-span" face="Monaco"><span class="Apple-style-span" style="font-size: 12px;"><br></span></font></div></body></html>