Dear Folks,
doing very basic one wire bit banging from wall socket nano every to basement relay controller uno. I was using the micro's before and they worked great, but now I got a couple nano every because "she told me 'they are just like the micro's'", turns out, they are not, really
So the very simple protocol goes like this
the nano every listens to a pin and send an 'address' on pin 13 if button is pushed:
if(digitalRead(2) == HIGH){
//send address 10101010
digitalWrite(10, HIGH);
delay(100);
digitalWrite(10, LOW);
delay(100);
digitalWrite(10, HIGH);
delay(100);
digitalWrite(10, LOW);
delay(100);
...
}
the uno, in the basement, listens to the wire change and writes the binary character:
if(digitalRead(10) == HIGH) {
unsigned byte character = 0;
delay(50);
bitWrite(character, 1, 7); //1xxxxxxx
delay(100);
if(digitalRead(10) == HIGH) {bitWrite(character, 1, 6);} //11xxxxxx
else{bitWrite(character, 1, 6); //10xxxxxx}
delay(100);
if(digitalRead(10) == HIGH) {bitWrite(character, 1, 5);} //1x1xxxxx
else{bitWrite(character, 1, 5); //1x0xxxxx}
delay(100);
if(digitalRead(10) == HIGH) {bitWrite(character, 1, 7);} //1xx1xxxx
else{bitWrite(character, 1, 7); //1xx0xxxxx}
delay(100);
....
}
but the character the uno reads is correct for the most significant bits, but it looks like lagging in the lsbits.
10000010 becomes 10000001
10000101 becomes 10000010
What is going on here? Is the bitwrite method taking so much overhead on the uno this cannot follow the 100ms delay, or is the nano every just not fit for the job?
PS: I have tried to program the nano every with avrdude directly, but that is even more of a mess ...
