0% found this document useful (0 votes)
133 views1 page

DS1821 Number Flashes - Ino

Arduino program. Sensor DS1821 measure temperature, then send to Arduino. LED on Arduino flash number corresponding to temperature in Celsius grad

Uploaded by

Dariusz Bartniak
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
133 views1 page

DS1821 Number Flashes - Ino

Arduino program. Sensor DS1821 measure temperature, then send to Arduino. LED on Arduino flash number corresponding to temperature in Celsius grad

Uploaded by

Dariusz Bartniak
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Plik: /home/dariusz/Arduino/DS1821_…shes/DS1821_number_flashes.

ino
Strona 1 z 1

// include the library code:


#include <OneWire.h>
#include <DallasTemperature.h>

#define ONE_WIRE_BUS_1 0
#define PotPin 2 // analog input pin at analog in 0
#define OutputPin 1 // output pin at 1

#define FlashDelay 200 //


#define PauseDelay 2000 //

int Temperature = 0; //

OneWire oneWire_1(ONE_WIRE_BUS_1);
DallasTemperature sensor_1(&oneWire_1);

void setup()
{
// Serial.begin(9600);
pinMode(OutputPin, OUTPUT); // sets the OutputPin pin as output
digitalWrite(OutputPin, LOW);
analogReference(DEFAULT); // ref=5V

void loop()
{
sensor_1.begin();
sensor_1.requestTemperatures();
Temperature = sensor_1.getTempCByIndex(0);
if (Temperature <= 0)
{
Temperature = 0;
}
for (int i=1; i <= Temperature; i++)
{
digitalWrite(OutputPin, HIGH);
delay(FlashDelay);
digitalWrite(OutputPin, LOW);
delay(FlashDelay);
}

delay(PauseDelay);

You might also like