I don't know how to get the led light to blink instead of glowing. =(
I don't know how to get the serial.println to print " Outside of the normal body temperature " when the temperature it's outside the stated range. Any help or resources would be appreciated. Thanks :). Below is the code :
#include <OneWire.h>
#include <DallasTemperature.h>
// Data wire is plugged into pin 2 on the Arduino
#define ONE_WIRE_BUS 2
// Setup a oneWire instance to communicate with any OneWire devices
// (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);
// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);
const uint8_t ledPin = 13; // LED connected to digital pin 13
void setup(void)
{
pinMode(ledPin, OUTPUT); // sets the digital pin as output
// start serial port
Serial.begin(9600);
Serial.println("Dallas Temperature IC Control Library Demo");
// Start up the library
sensors.begin();
}
void loop(void)
{
// call sensors.requestTemperatures() to issue a global temperature
// request to all devices on the bus
Serial.print(" Celsius Requesting temperature...");
sensors.requestTemperatures(); // Send the command to get temperatures
Serial.println("DONE");
float temp = sensors.getTempCByIndex(0);
Serial.print(" Core Body Temperature: ");
Serial.print(temp);
// You can have more than one IC on the same bus.
// 0 refers to the first IC on the wire
if (temp < 35 || temp > 39.4)
digitalWrite(ledPin, HIGH);
else
digitalWrite(ledPin, LOW);
}
[code]
Thank you for all your help.
The light is not blinking
#include <OneWire.h>
#include <DallasTemperature.h>
// Data wire is plugged into pin 2 on the Arduino
#define ONE_WIRE_BUS 2
// Setup a oneWire instance to communicate with any OneWire devices
// (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);
// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);
const uint8_t ledPin = 13; // LED connected to digital pin 13
void setup(void)
{
pinMode(ledPin, OUTPUT); // sets the digital pin as output
// start serial port
Serial.begin(9600);
Serial.println("Dallas Temperature IC Control Library Demo");
// Start up the library
sensors.begin();
}
void loop(void)
{
// call sensors.requestTemperatures() to issue a global temperature
// request to all devices on the bus
Serial.print(" Celsius Requesting temperature...");
sensors.requestTemperatures(); // Send the command to get temperatures
float temp = sensors.getTempCByIndex(0);
Serial.print(temp);
// You can have more than one IC on the same bus.
// 0 refers to the first IC on the wire
if (temp < 35 || temp > 39.4){
digitalWrite(ledPin, HIGH);
delay(100);
Serial.println ("Celsius, outside normal body temperature range");
}
else{
digitalWrite(ledPin, LOW);
Serial.println ("Celsius, within of normal body temperature range");
}}
[code]
[code][code]whats the line to turn it off????. The following code is not working: [/code]
#include <OneWire.h>
#include <DallasTemperature.h>
// Data wire is plugged into pin 2 on the Arduino
#define ONE_WIRE_BUS 2
// Setup a oneWire instance to communicate with any OneWire devices
// (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);
// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);
const uint8_t ledPin = 13; // LED connected to digital pin 13
void setup(void)
{
pinMode(ledPin, OUTPUT); // sets the digital pin as output
// start serial port
Serial.begin(9600);
Serial.println("Dallas Temperature IC Control Library Demo");
// Start up the library
sensors.begin();
}
void loop(void)
{
// call sensors.requestTemperatures() to issue a global temperature
// request to all devices on the bus
Serial.print(" Requesting temperature...");
sensors.requestTemperatures(); // Send the command to get temperatures
float temp = sensors.getTempCByIndex(0);
Serial.print(temp);
// You can have more than one IC on the same bus.
// 0 refers to the first IC on the wire
if (temp < 35 || temp > 39.4){
digitalWrite(ledPin, HIGH);
delay(1000);
digitalWrite(ledPin, LOW); // sets the LED off
delay(1000); // waits for a second
}
Serial.println (" Celsius,outside the normal body temperature range");
}
else{
digitalWrite(ledPin, LOW);
Serial.println (" Celsius, within the normal body temperature range");
}
}
[/code]
I get the following error :
message:50: error: expected unqualified-id before 'else'
message:54: error: expected declaration before '}' token