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.
 
 

29 lines
531 B

#include "Arduino.h"
#include "SerialChannel.h"
short SerialChannel::nextId = 0;
SerialChannel::SerialChannel()
{
}
void SerialChannel::init(const char* name)
{
id = nextId++;
Serial.write((short)0);
Serial.write(id);
Serial.write(strlen(name));
Serial.write(name);
}
void SerialChannel::write(byte* data, short byteCount)
{
Serial.write(byteCount);
Serial.write(id);
Serial.write(data, byteCount);
}
void SerialChannel::write(const char* text)
{
Serial.write((byte*)text, strlen(text));
}