Arduino Uno resets (don't keep its programmation) when power change from USB to battery

Discussion in 'Embedded Systems and Microcontrollers' started by Tainara, Oct 2, 2015.

  1. Tainara

    Thread Starter New Member

    Sep 10, 2014
    6
    2
    Hello.

    I need some help, please.

    I am having a problem with my arduino uno: after I upload the program to arduino board through usb cable and take it off to power arduino with a 9V external battery seems like it resets, I mean when I connect the battery and arduino is powered again the program uploaded before is lost.

    I read a possible reason could be the eeprom cycles reached its limit but I just bought the arduino board I'm using recently and didn't uploaded that much programs on it to reach the limit of cycles.

    Maybe because I'm using serial communication can this be interferring?
    Well, don't know if it's relevant but that's my code program:
    Code (Text):
    1. const int sensor = A1;       // sensor on analogue pin
    2.  
    3. void setup()
    4. {
    5.   // initialize the serial communications:
    6.   Serial.begin(9600);
    7.  
    8.   analogReference(EXTERNAL); //ADC takes its reference voltage from AREF pin (3V which is the voltage I powered the sensor)
    9.  
    10.   pinMode(sensor, INPUT); //A1 as input pin
    11.  
    12.  
    13. }
    14.  
    15. void loop()
    16. {
    17.   // print the sensor values:
    18.   Serial.print(analogRead(sensor));
    19.   // print x between values:
    20.   Serial.print("x");
    21.   delay(10);
    22.  
    23. }
    Does anyone know something I can try to solve it?
     
Loading...