
Originally Posted by
PaulStoffregen
Try adding pinMode(12, INPUT);
On Teensy3, the digital pins default to disable, not inputs. You need to use pinMode to make the pin act as an input.
Thanks Paul good to know, I wish I know that befor, man that freaked me out but now there is it DS18B20 slavemode for the T3.
This is the Sketch for the T3 and the libs are in the attachment.
Code:
#include <OneWireSlave.h>
// {Fami, <---, ----, ----, ID--, ----, --->, CRC}
unsigned char rom[8] = {0x28, 0xAD, 0xDA, 0xCE, 0x0F, 0x00, 0x11, 0x00};
// {TLSB, TMSB, THRH, TLRL, Conf, 0xFF, Rese, 0x10, CRC}
unsigned char scratchpad[9] = {0x7F, 0x09, 0x4B, 0x46, 0x7F, 0xFF, 0x00, 0x10, 0x00};
// {TLSB, TMSB}
unsigned char scratchpadtemperature[2] = {0x7F, 0x09};
OneWireSlave ds(12);
//Interrupt
volatile long previousmicros = 0;
volatile long old_previousmicros = 0;
volatile long difference = 0;
//Blinking
const int ledPin = 13;
int ledState = LOW; // ledState used to set the LED
long previousMillis = 0; // will store last time LED was updated
long interval = 750; // interval at which to blink (milliseconds)
void setup() {
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
pinMode(12, INPUT);
ds.init(rom);
ds.setScratchpad(scratchpad);
ds.setPower(PARASITE);
ds.setResolution(9);
attachInterrupt(12, DS18B20, CHANGE);
ds.attach44h(temper);
}
void loop() {
blinking();
//ds.waitForRequest(false);
}
void temper() {
scratchpadtemperature[0] = scratchpadtemperature[0] + 1;
ds.setTemperature(scratchpadtemperature);
}
void DS18B20() {
old_previousmicros = previousmicros;
previousmicros = micros();
difference = previousmicros - old_previousmicros;
if (difference >= 330 && difference <= 500) {
ds.waitForRequestInterrupt(false);
}
}
void blinking() {
unsigned long currentMillis = millis();
if(currentMillis - previousMillis > interval) {
previousMillis = currentMillis;
ledState = !ledState;
digitalWrite(ledPin, ledState);
}
}
If I have more time next, I will make it smarter the next days, wishes welcome.