Hi,
first sorry for my english
Secondly: I have a problem with a Promini module to which I have connected an infrared barrier and which at the time of the interruption of the beam illuminates the LED. Circuit and sketch works just how you should just connect to your PC via FDTI and refuse to work when the USB is disconnected and the external battery is connected
I checked the voltage both for the USB connection and the connection to the battery and they are the same. Interestingly, when I disconnect RX / TX from FDTI it works perfectly.
here is sketch's
const byte IR_LED = 3;
const byte IR_Receiver = 2;
const byte onboard_LED = 13;
boolean receiverState;
#define debug
void setup() {
Serial.begin(9600);
#ifdef debug
Serial.begin(9600);
while(!Serial);
#endif
pinMode (onboard_LED, OUTPUT);
pinMode (IR_LED, OUTPUT);
pinMode (IR_Receiver, INPUT);
TCCR2A = _BV (COM2A0) | _BV(WGM21);
TCCR2B = _BV (CS20);
OCR2A = 209; // ~209 = ~38kHz | ~219 = ~36kHz
}
void loop() {
receiverState = digitalRead (IR_Receiver);
if (receiverState == LOW) {
digitalWrite(onboard_LED, LOW);
}
else {
digitalWrite(onboard_LED, HIGH);
delay(150);
}
}