I have a GP2Y0A21YK0F Sharp IR Analog Distance Sensor 10-80cm + Cable, Arduino Compatible and its is connected to my Arduino. All works well and I can read the analog data with the following code:
#include <SoftwareSerial.h>
#define RX 2 // receive
#define TX 3 // transmit
#define SEN1 4
SoftwareSerial mySerial = SoftwareSerial(RX, TX);
void setup()
{
mySerial.begin(4800);
mySerial.println("Hello, world?");
}
void loop() // run over and over
{
int reading = analogRead(SEN1);
mySerial.println(reading);
delay(500);
}
When the code runs on the Attiny with the GP2Y0A21YK0F
IR Sensor connected, the Attiny84 resets over and over. The Attiny84 and GP2Y0A21YK0F
are part of the same circuit e.g. Attiny and GP2Y0A21YK0F
share the power and ground rail.
When I disconnect the GP2Y0A21YK0F
, the program runs and stops resetting. I was able to reproduce this on an Attiny85 and ATMega328.
The strange thing is, it works fine on the Arduino. Any help is greatly appreciated.
GP2Y0A21YK0F
seems to work. Awesome :)! – PhillyNJ Sep 14 '14 at 12:00