Hi Larry,
Thanks for getting back to me, i’m still a bit of a newbie so you’ll have to bare with me. I’ve attached an image of my setup, the IR runs of 3.3-5v so i assumed it was ok to setup as i have.
As i mentioned i’m using a combination of imp examples and arduino to try and get it to work, but i’m not 100% sure i’m doing it right. All i need to get is the proximity values so i can tell how close someone is to it.
My basic code was trying to take the below from arduino and translate it to squirrel. All this code is currently doing is checking if its working.
Hope thats enough information thanks again, if you can give me any advice it would be really appreciated
Lloyd
/***** Arduino *****/
`
#include <Wire.h>
#define VCNL4000_ADDRESS 0x13 //I2C Address of the board
void setup(){
byte temp = readVCNLByte(0x81);
if (temp != 0x11){ // Product ID Should be 0x11
Serial.print(“initVCNL4000 failed to initialize”);
Serial.println(temp, HEX);
}else{
Serial.println(“VNCL4000 Online…”);
}
}
byte readVCNLByte(byte address){
// readByte(address) reads a single byte of data from address
Wire.beginTransmission(VCNL4000_ADDRESS);
Wire.write(address);
Wire.endTransmission();
Wire.requestFrom(VCNL4000_ADDRESS, 1);
while(!Wire.available());
byte data = Wire.read();
return data;
}
`
/***** Imp *****/
`
hardware.i2c12.configure(CLOCK_SPEED_400_KHZ);
local i2c = hardware.i2c12;
function readProximity()
{
i2c.write(0x13, “\x81” + “”);
imp.sleep(1.0);
local temp = i2c.read(0x13, “\x81”, 1);
server.log(“Temp” + temp);
}
readProximity();
`