Pages: [1]   Go Down
Author Topic: I2C issue on Arduino Nano  (Read 753 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

I am trying to install ADT7420 digital temperature sensor to Arduino Nano.
I have written a sketch for Arduino UNO, it works on Arduino UNO very well.
But same sketch couldn't work on Arduino NANO smiley-confuse

Could you kindly tell me what is wrong?
Please help me smiley-red

Code:
#include <I2C.h>
#define ADT 0x48

int i,ans;
long temp;      
double celsius;  

void setup()
{
  I2c.begin();                  
  Serial.begin(9600);          
  delay(10);                    
  I2c.read(ADT,0x0B,1);        
  byte st=I2c.receive();      
  Serial.print("ID:(0xCB):");  
  Serial.println(st, HEX);    
}

void loop()
{
  int i;
  byte xH,xL;

  Serial.print("temp:");    
  I2c.read(ADT,0x0,2);      
  xH = I2c.receive();        
  xL = I2c.receive();        
  /*Serial.print(xH,HEX);  
  Serial.print(xL,HEX);    
  Serial.print(": ");*/
  celsius = double(long(word(xH,xL)) * 100/128)/100.00;  
  Serial.print(celsius);    
  Serial.println("deg");    
  delay(500);                
}

I use SCL as A5, SDA as A4.
« Last Edit: April 22, 2013, 04:36:48 am by junkai » Logged

Pages: [1]   Go Up
Jump to: