9V Battery constantly resets Arduino Uno


I have an Arduino Uno set up with a few LED's 100OHM resistors on those and a couple buttons.

After around 10 minutes of the project being powered on by a 9V battery, it starts to do this: https://www.youtube.com/watch?v=o8okdYq0B5Y

I'm basically new to all of this so it might be in my code, take a look

int led1 = 13;
int led2 = 12;
int led3 = 11;
int ledready = 10;
int led4 = 9;
int button2 = 6;
int button2 = 7;
int light = 0;
int speaker = 8;

int ledTimeDelay = 1000;

boolean pressed = LOW;

boolean button1State = LOW;
boolean button2State = LOW;

void setup() {                
  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);
  pinMode(led3, OUTPUT);
  pinMode(led4, OUTPUT);
  pinMode(ledready, OUTPUT);
  pinMode(button1, INPUT);
  pinMode(button2, INPUT);
  pinMode(light, INPUT);
  digitalWrite(ledready, 1);

void loop() {
  button1State = digitalRead(button1);
  button2State = digitalRead(button2);
  if(button1State == HIGH){
      digitalWrite(led1, HIGH);
      digitalWrite(led2, HIGH);
      digitalWrite(led3, HIGH);
      digitalWrite(led4, HIGH);
      armed = HIGH;
      Serial.println("Pressed state is currently: ");
      if(pressed == HIGH){
        Serial.println("Successfully pressed and variable set, and ready to press 2nd button."); 
        Serial.println("Failed to set pressed variable.");
  if(button2State == HIGH && pressed == HIGH){
    digitalWrite(led1, LOW);
    digitalWrite(led2, LOW);
    digitalWrite(led3, LOW);
    digitalWrite(led4, LOW);
    digitalWrite(led1, HIGH);
    digitalWrite(led2, HIGH);
    digitalWrite(led3, HIGH);
    digitalWrite(led4, HIGH);
    Serial.println("Variable and button combo successfull"); 


The PP3 type of 9v battery can't supply enough current to run an Arduino.


Did you do some calculations that lead you to the use of 100 Ohm resistors ? That seems a bit low to me. 9 volts batteries don't have a lot of energy. They are empty before you know it. Can you do some measurements using a multimeter ?

I don't have one of those, and I didn't have 220 OHM like recommended on Arduino's website, only 100 and 470 OHM and 470 is too strong

Should I get one of these? https://secure.robotshop.com/adafruit-battery-holder-barrel-jack.html

Replace the resistors with 1k if you have them, else the closest you have (exact values are not critical), and or, drop down to just one led to test, and reduce its duty cycle. Besides the battery dropping out, it could also be the 5 volt regulator onboard that is over heating and shutting off. If you can hold your finger on the regulator for 5 seconds without a blister you, it is probably not overheating.

edwinforthewin: I didn't have 220 OHM like recommended on Arduino's website, only 100 and 470 OHM and 470 is too strong

If you have to make a choice, NEVER choose a lower value resistor for this function. Always choose higher values. Next time use 2 or 3 resistors instead. You can make a 300 Ohm resistor by putting 3 100 Ohm resistors in series. And you can make a 235 Ohm resistor by putting 2 475 Ohm resistors in parallel.

I can't see how you wired your LED's, so i don't know if you did put those resistors in series to create a larger one.