An arduino library to communicate using the Dallas one-wire protocol, where the Arduino takes the role of a slave. Implementation of a DS2413 on Arduino UNO and ATTINY85
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

49 lines
721 B

#include "Arduino.h"
#include "LowLevel.h"
#include "SerialChannel.h"
#include "OneWireSlave.h"
#define LEDPin 13
#define OWPin 2
SerialChannel debug("debug");
Pin led(LEDPin);
byte owROM[7] = { 0xE2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 };
OneWireSlave oneWire(owROM, OWPin);
void setup()
{
led.outputMode();
led.writeLow();
oneWire.enable();
Serial.begin(9600);
}
int count = 0;
void loop()
{
delay(1);
if (count++ == 1000)
{
led.write(!led.read());
count = 0;
}
cli();//disable interrupts
SerialChannel::swap();
sei();//enable interrupts
SerialChannel::flush();
byte b;
if (oneWire.read(b))
{
char msg[32];
sprintf(msg, "Received byte : %d", (int)b);
debug.write(msg);
}
}