hi im having trouble appling code lilypad aurduino usb , wondering if point me in right direction im going wrong? code im using below:
#include <wire.h>
// simple ds1621 demo
// -- jon mcphalen (www.jonmcphalen.com)
// -- 19 dec 2007
// ds1621 has a2, a1, , a0 pins connected gnd
#define dev_id 0x90 >> 1 // shift required wire.h
void setup()
{
serial.begin(9600);
wire.begin();
wire.begintransmission(dev_id); // connect ds1621 (#0)
wire.write(0xac); // access config
wire.write(0x02); // set continuous conversion
wire.begintransmission(dev_id); // restart
wire.write(0xee); // start conversions
wire.endtransmission();
}
void loop()
{
int tempc = 0;
int tempf = 0;
delay(1000); // give time measurement
wire.begintransmission(dev_id);
wire.write(0xaa); // read temperature
wire.endtransmission();
wire.requestfrom(dev_id, 1); // request 1 byte ds1621
tempc = wire.read(); // whole degrees reading
tempf = tempc * 9 / 5 + 32; // convert fahrenheit
serial.print(tempc);
serial.print(" / ");
serial.println(tempf);
}
#include <wire.h>
// simple ds1621 demo
// -- jon mcphalen (www.jonmcphalen.com)
// -- 19 dec 2007
// ds1621 has a2, a1, , a0 pins connected gnd
#define dev_id 0x90 >> 1 // shift required wire.h
void setup()
{
serial.begin(9600);
wire.begin();
wire.begintransmission(dev_id); // connect ds1621 (#0)
wire.write(0xac); // access config
wire.write(0x02); // set continuous conversion
wire.begintransmission(dev_id); // restart
wire.write(0xee); // start conversions
wire.endtransmission();
}
void loop()
{
int tempc = 0;
int tempf = 0;
delay(1000); // give time measurement
wire.begintransmission(dev_id);
wire.write(0xaa); // read temperature
wire.endtransmission();
wire.requestfrom(dev_id, 1); // request 1 byte ds1621
tempc = wire.read(); // whole degrees reading
tempf = tempc * 9 / 5 + 32; // convert fahrenheit
serial.print(tempc);
serial.print(" / ");
serial.println(tempf);
}
by applying, mean uploading unmodified sketch written else? if so, expect work, first place @ hardware.
Arduino Forum > Using Arduino > Programming Questions > lilypad usb temp sensor using ds1621
arduino
Comments
Post a Comment