Problem with connecting Nano v3 to Sharp Proximity Sensor


i trying connect a sharp analog ir distance sensor gp2y0e02a nano v3. accepts 2.7 - 3.3 v have connected 3.3 v arduino dont serial output, complete blank.. not sure why since copied code identically bottom of page (http://www.robot-electronics.co.uk/htm/arduino_examples.htm)

here pic took of circuit on breadboard: http://imgur.com/a/8nshu

code: [select]

/***************************************************************
  arduino gp2y0e02b example code
  gets range gp2y0e02b , prints serial monitor.

  james henderson 2014
***************************************************************/

#include <wire.h>

int distance = 0;                // stores calculated distance
byte high, low = 0;              // high , low byte of distance
int shift = 0;                   // value in shift bit register

#define address       0x80 >> 1  // arduino uses 7 bit addressing shift address right 1 bit
#define distance_reg  0x5e
#define shift         0x35

void setup()
{
  // start comms
  wire.begin();
  serial.begin(19200);
 
  delay(50);  // delay can power up
 
  // read sift bit register module, used in calculating range
  wire.begintransmission(address);   
  wire.write(shift);
  wire.endtransmission();
 
  wire.requestfrom(address, 1);
  while(wire.available() == 0);
  shift = wire.read();
}

void loop()
{
  // request , read 2 address bytes gp2y0e02b
  wire.begintransmission(address);
  wire.write(distance_reg);
  wire.endtransmission();
 
  wire.requestfrom(address, 2);
 
  while(wire.available() < 2);
 
  high = wire.read();
  low = wire.read();
 
  distance = (high * 16 + low)/16/(int)pow(2,shift); // calculate range in cm
 
  serial.print("distance ");
  serial.print(distance);
  serial.println("cm");
 
  delay(50);
}

from sensor datasheet: "please use electric source output current of 150ma or more because led pulse current more 100ma".

the 3.3volt output of official nano tops @ 50ma. clone not half of that.
an uno/mega (150ma) ok.
leo..


Arduino Forum > Using Arduino > Sensors > Problem with connecting Nano v3 to Sharp Proximity Sensor


arduino

Comments

Popular posts from this blog

Error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode - Raspberry Pi Forums

class MPU6050 has no member named begin

missing filename after '-o'