Hello everyone!
I have 1-wire dual switch ds2406p.
Datasheet for ds2406p here:
I tryed to write code to read state of one of digital inputs of ds2406 (input PIO A).
I used library OneWire.h from here http://www.pjrc.com/teensy/arduino_libraries/OneWire.zip
I wrote some code:
#include <OneWire.h>
OneWire ds(9);
uint8_t address[8] = {0x12, 0x2E, 0xED, 0x3D, 0, 0, 0, 0xC7};
uint8_t CHANNEL_ACCESS = 0xF5;
uint8_t CHANNEL_CONTROL_BYTE = 0x44; //ALR=0;IM=1;TOG=0;IC=0;CHS1=0;CHS0=1;CRC1=0;CRC0=0
uint8_t buffer;
void setup(void)
{
Serial.begin(9600);
} //end setup
void loop(void)
{
ds.reset();
ds.select(address);
ds.write(CHANNEL_ACCESS,1);
ds.write(CHANNEL_CONTROL_BYTE,1);
ds.write(0xFF,1);
ds.write(CHANNEL_CONTROL_BYTE,1);
ds.write(0xFF,1);
buffer = ds.read();
ds.reset();
Serial.println(buffer);
delay(2000);
} //end loop
But, on a serial monitor a have always "255".
Please help
Thanks.
ArduinoMEGA
Linux Ubuntu
9600 baud