I have a bit of a strange issue here with a Nano. When I run the code below, It mostly works as expected. When I comment out the Serial.Begin(38400); It still works, but the TX light basically stays on, and pulses brighter about once a second. In both cases, if you change the baud rate in the serial monitor (which never shows anything, as expected by code), the arduino nano seems to reset. Also, when running from battery only, the pwr light pulses about twice a second. It stays on, just gets brighter for a moment. When plugged into usb (VIN is still connected to battery and has power), the PWR light doesn't pulse.
int p1 = 0, p2 = 0, p3 = 0, p4 = 0, check = 0;
void setup() {
// put your setup code here, to run once:
Serial.begin(38400);
analogWrite(9, p1);
analogWrite(6, p2);
analogWrite(5, p3);
analogWrite(3, p4);
p1 = 30;
p2 = 30;
p3 = 30;
p4 = 30;
}
void loop() {
// put your main code here, to run repeatedly:
if (check == 0) {
analogWrite(9, p1);
analogWrite(6, p2);
analogWrite(5, p3);
analogWrite(3, p4);
check = 1;
}
}
This code was meant as a test when my previous W.I.P. code started giving me trouble. It would set the values for p1-p4, analogWrite them (as coded), then turn them off for no apparent reason after a random time between about 500ms and 3000ms(not coded, the shutdown is a bug). p1-p4 still had good values when this happened. This is the reason for the check variable and the if statement above, so the analogWrite would only happen once. The previous issue that I was initially testing for (random shutdown) does not happen in the above code.
Hopefully I havn't thoroughly confused everyone, and in case I have: I am not looking to solve my shutdown issue here, thats just explaining the point of the above code. Here are my issues:
- TX light on and pulsing with no Serial.begin()
- PWR light pulsing when powered by battery only, but not with battery and usb
Each output pin goes through a 390ohm resistor to the gate of a mosfet. The mosfet sits low-side in series with a motor, using the same battery supplying VIN on the nano. These circuits work as expected. Not sure if this matters, but I thought I'd include it just in case.
I fear this nano may already be laying in its coffin waiting for the lid to fall. Unfortunately, it is already mounted on the project, so I'm hoping its fixable. Any ideas?
Thanks,
Kyrle
More Info:
I did some poking around with a DMM. When the TX light is on and pulsing, the RX pin has a little over 6v. This is the only place in the entire circuit with that voltage. The 5v line stays right at 5v. The Tx pin stays around 100mV.
Update:
Decided to check if serial communication was even working. So, I turned everything on and went to plug it in to upload a basic echo serial test. Before plugging it in, I noticed the TX, RX and PWR lights were all on. Pressed reset, the TX light went off, then came back on. When I plugged in the USB, nothing happened, it was not detected and the IDE could not upload the sketch.
I am going to give it a break for the day. Hopefully stepping away will clear my head and give you guys some time to offer ideas. Hopefully I wont be ordering a new nano tomorrow and swapping them out. I'd appreciate any ideas you guys can offer to help me prevent that.