2015-04-11 20:28:53 +02:00
|
|
|
#include "Arduino.h"
|
2015-04-23 17:26:33 +02:00
|
|
|
#include "LowLevel.h"
|
2015-04-11 20:28:53 +02:00
|
|
|
#include "SerialChannel.h"
|
2015-04-25 13:04:10 +02:00
|
|
|
#include "OneWireSlave.h"
|
2015-04-11 12:49:46 +02:00
|
|
|
|
2015-04-11 13:18:12 +02:00
|
|
|
#define LEDPin 13
|
2015-04-23 17:26:33 +02:00
|
|
|
#define OWPin 2
|
2015-04-24 12:13:29 +02:00
|
|
|
|
2015-04-12 12:16:54 +02:00
|
|
|
SerialChannel debug("debug");
|
2015-04-11 13:18:12 +02:00
|
|
|
|
2015-04-24 10:30:11 +02:00
|
|
|
Pin led(LEDPin);
|
2015-04-23 17:26:33 +02:00
|
|
|
|
2015-04-25 13:04:10 +02:00
|
|
|
byte owROM[7] = { 0xE2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 };
|
|
|
|
OneWireSlave oneWire(owROM, OWPin);
|
2015-04-23 18:56:18 +02:00
|
|
|
|
2015-04-11 13:18:12 +02:00
|
|
|
void setup()
|
|
|
|
{
|
2015-04-24 10:30:11 +02:00
|
|
|
led.outputMode();
|
|
|
|
led.writeLow();
|
2015-04-11 13:18:12 +02:00
|
|
|
|
2015-04-25 13:04:10 +02:00
|
|
|
oneWire.enable();
|
2015-04-11 20:28:53 +02:00
|
|
|
|
2015-04-24 11:29:59 +02:00
|
|
|
Serial.begin(9600);
|
2015-04-11 12:49:46 +02:00
|
|
|
}
|
|
|
|
|
2015-04-25 21:40:38 +02:00
|
|
|
int count = 0;
|
2015-04-11 13:18:12 +02:00
|
|
|
void loop()
|
|
|
|
{
|
2015-04-25 21:40:38 +02:00
|
|
|
delay(1);
|
|
|
|
if (count++ == 1000)
|
2015-04-25 13:04:10 +02:00
|
|
|
{
|
2015-04-25 12:19:31 +02:00
|
|
|
led.write(!led.read());
|
2015-04-25 13:04:10 +02:00
|
|
|
count = 0;
|
2015-04-25 21:40:38 +02:00
|
|
|
}
|
2015-04-25 13:04:10 +02:00
|
|
|
|
2015-04-24 20:17:29 +02:00
|
|
|
cli();//disable interrupts
|
2015-04-23 18:56:18 +02:00
|
|
|
SerialChannel::swap();
|
2015-04-24 20:17:29 +02:00
|
|
|
sei();//enable interrupts
|
|
|
|
|
2015-04-23 18:56:18 +02:00
|
|
|
SerialChannel::flush();
|
2015-04-25 00:06:00 +02:00
|
|
|
|
2015-04-25 13:04:10 +02:00
|
|
|
byte b;
|
|
|
|
if (oneWire.read(b))
|
2015-04-24 20:17:29 +02:00
|
|
|
{
|
2015-04-25 13:04:10 +02:00
|
|
|
char msg[32];
|
|
|
|
sprintf(msg, "Received byte : %d", (int)b);
|
|
|
|
debug.write(msg);
|
2015-04-24 22:34:55 +02:00
|
|
|
}
|
|
|
|
}
|