Volgens het schema zit daar niets op aangesloten dus dat maakt niet uit.Waarom zitten er 3x2 = 6 aansluitingen als je maar 3 nodig bent (LN-in, LN-uit en massa)?
Welke library gebruik je voor LocoNet? Ik wil ook beginnen aan een Arduino met LocoNet.Groet,Bert
#include <LocoNet.h>int offset = 1; //number in fictitious s88 chain#define TX_PIN 6// pin 8 is receivingstatic LnBuf LnTxBuffer;static lnMsg *LnPacket;byte IN1;byte IN2 = 255;byte broadcast = 255;byte address_received = 255;byte numSensors = 1;int j;int sensorPins[16] = {A0,A1,A2,A3,A4,A5,0,2,3,4,5,6,7,9,10,12};int sensorValue[16] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};int lastsensorValue[16] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};unsigned long sensorprevmillis[16];unsigned long currentmillis;unsigned long interval = 500;//-------------------void setup(){ offset = ((offset - 1) * 16) + 1; //1 = adres 1 t/m 16, 2 = adres 17 t/m 32 etc. for (j=0; j<16; j++) pinMode(sensorPins[j], INPUT_PULLUP); pinMode(13,OUTPUT); digitalWrite(13,LOW); Serial.begin(57600); Serial.println("Hallo, i am awake!!"); LocoNet.init(TX_PIN); initLnBuf(&LnTxBuffer); IN1 = address_received; IN1 = IN1 >> 1; bitClear (IN1,7); bitSet (IN2,6); bitWrite (IN2,5, bitRead(address_received,0));}//---------------------void loop(){ LnPacket = LocoNet.receive(); if(LnPacket) { printRXpacket(); if (LnPacket -> data[0] == 0x83) sendALLsensors(); } for (j=0; j<16; j++) processSensor(j);}//----------------------void printRXpacket (){ uint8_t Length = getLnMsgSize( LnPacket ) ; Serial.print("RX: "); for (uint8_t Index = 0; Index < Length; Index++) { Serial.print(LnPacket->data[ Index ], HEX); Serial.print(" "); } Serial.println();}//-----------------------void sendTXtoLN (byte firstbyte, byte secondbyte){ byte checksum = 0xFF - (0xB2^ firstbyte ^ secondbyte); addByteLnBuf(&LnTxBuffer, 0xB2); addByteLnBuf(&LnTxBuffer, firstbyte); addByteLnBuf(&LnTxBuffer, secondbyte); addByteLnBuf(&LnTxBuffer, checksum); LnPacket = recvLnMsg( &LnTxBuffer); if (LnPacket) { LocoNet.send( LnPacket ); Serial.print("TX: "); Serial.print(" "); Serial.print(firstbyte); Serial.print(" "); Serial.print(secondbyte, HEX); Serial.print(" "); Serial.print(checksum, HEX); Serial.println(); }}//----------------------------------------- void sendALLsensors (){ byte tempaddr; for (j=0; j<16; j++) { tempaddr = address_received + j; IN1 = tempaddr; IN1 = IN1 >> 1; bitClear (IN1,7); bitSet (IN2,6); bitWrite (IN2,5, bitRead(tempaddr,0)); bitWrite (IN2,4, !sensorValue[j]); sendTXtoLN (IN1, IN2); }}//------------------------------------void processSensor (int sensornumber){ sensorValue[sensornumber] = digitalRead(sensorPins[sensornumber]); currentmillis = millis (); byte tempaddr = 0; byte byte1 = 0; byte byte2 = 0; if ((sensorValue[sensornumber] != lastsensorValue[sensornumber]) && (currentmillis - sensorprevmillis [sensornumber] > interval)) { lastsensorValue[sensornumber] = sensorValue[sensornumber]; sensorprevmillis [sensornumber] =currentmillis; tempaddr = address_received + sensornumber + offset; byte1 = tempaddr; byte1 = byte1 >> 1; bitClear (byte1,7); bitSet (byte2,6); bitWrite (byte2,5, bitRead(tempaddr,0)); bitWrite (byte2,4, !sensorValue[sensornumber]); sendTXtoLN (byte1, byte2); }}