Need help with resistors

It's my first time to use arduino and im a product designer, so its not exactly my thing..the problem i'm facing right now is that i'm using a pushbutton with 2 LEDs as outputs, whats supposed 2 happen is the first LED should stay on and the second LED should blink... it does work, but the blinking is not strong.. its like its only blinking from inside with a very small intensity, how do i get it to blink strongly, that it all lights and goes off? is that something wrong with the way i've connected the wires and stuff? or where is the problem?

would really appreciate it if someone could help me understand.. :slight_smile:

i'm using a 10k resistor, and the first one is connected to the pushbutton and the ground, but where do i connect the second one? or do i only use one?

would really appreciate it if someone could help me understand..

Lots of help available around here. However you need to learn how to help us help you. You must post your sketch, otherwise how could we possibly know what you might have done wrong?

Post your code inside a code window by using the # button at the top of the edit window.

Also a wiring diagram is often required to see if you wired something wrong. You are using series current limiting resistors with your leds, right?

You are properly providing a pull-up or pull-down for you switch inputs to prevent 'floating input pins', right?

You are properly using the pinMode() statements for your led output pins, right?

Lefty

first of all.. i have no idea how to post a diagram of the wiring and stuff.. :-[

and i'm sure there's nothing wrong with the code.. because it worked before.. but i changed a few things and can't get it to work again. The current status is that it's blinking only inside the LED which is very low and i don't why, except that i can't seem to remember how to link the 2nd resistor to it again. but just incase, i will post the code for you to understand what i'm doing:

define LED 13 // THE PIN FOR THE LED
#define SENS1 0


//VARIABLES 
int state = 0;
int currentInput = 1;
int currentOutput = 7;

int sensorValue = 0;
int oldSensorValue=0;
boolean blinking = false;


void setup () {
  pinMode (7, OUTPUT); //tell Arduino LED is an output
  
  pinMode (1, INPUT);
}

void loop (){

  oldSensorValue = sensorValue;
  sensorValue = digitalRead(currentInput); 

  if(sensorValue == HIGH && oldSensorValue == LOW){
   state= 1-state;
      digitalWrite(currentOutput, HIGH);
      delay(3000);
      
  if(sensorValue == HIGH && blinking == true){
      blinking = false;
    }
    else if(sensorValue == HIGH && blinking == false){
      blinking = true;
    }

   

  
      
    }
    if (blinking == true) {
     
    
    //START BLINKING
   { digitalWrite(currentOutput+1, LOW); // turn LED OFF
    delay(200);
    digitalWrite(currentOutput+1, HIGH); // turn LED OFF
    delay(200);}
    
    
  }
  
    if (currentInput+1 == HIGH){
      
      digitalWrite(currentOutput+1, HIGH);
   }
    
  }


//reads an input and gives an output

thank you soooo much for ur fast reply! =)

oh yeah.. and i didnt understand the part about the pull-up or pull-down for the switches? what does that mean?

and the pinMode is correct i guess..

excuse my ignorance... i've never done anything connected to programming code or electronics before.. =)

Are you using the 10k to connect the LED?

nope.. the 10 k resistor is connected to the pushbutton and the ground the LED is just connected to the ground. honestly, I dnt know what the resistor is for, but i copied it from a diagram in the book "Getting started with Arduino."

I dnt know what the resistor is for, but i copied it from a diagram in the book "Getting started with Arduino."

the resistor is used to connect the switch to ground if its in open state so that the arduino can read the pin :slight_smile:

  pinMode (1, INPUT);

This sets the mode for digital pin 1. Analog pins are INPUT only, so they don't need to be set. Using names for the pins is much better than using numbers.

Certainly many software errors I believe. Some are here:

{ digitalWrite(currentOutput+1, LOW); // turn LED OFF
    delay(200);
    digitalWrite(currentOutput+1, HIGH); // turn LED OFF
    delay(200);}

and here:

 if (currentInput+1 == HIGH){

      digitalWrite(currentOutput+1, HIGH);
   }

Those currentOutput+1 one and currentInput+1 cause the program to try and output and input to pins 8 and 2 respectively. And as you have only performed pinMode() commands on pins 7 and 1 your are writing and reading to the wrong pin numbers?

More importantly I would like to nail down your wiring of the led(s?) and switch(s?) as even if you correct all the software errors, the program won't work if the wiring is wrong. I know you said you can't post a drawing, but how about a detailed description of the switch and led wiring? As in one terminal of switch wires to ??, other end of switch wires to ??, one end of resistor wires to ?? or end of resistor wires to ??. Cathode lead of led wires to ??, anode end wires to ??. If you did not use a series wired resistor with your led you may have burned out the arduino output pin, but maybe not as you don't seem to be addressing the pin numbers correctly anyway. Also your original description talked about 'two leds', but I only see one pinMode() statement for one output pin?

I'm sure we can figure this all out given enough details. Hang in there.

Lefty

ok.. so now, do u have any idea how i can get the second LED to blink strongly( because the light intensity is very low, its just a small spot inside the LED that u can barely see)

ok.. so now, do u have any idea how i can get the second LED to blink strongly( because the light intensity is very low, its just a small spot inside the LED that u can barely see)

Read my last posting. Your code doesn't have a pinMode() statement for a second led digital output pin. But please don't fix that until we see if you are using a resistors (and correct size) for both the leds.

Lefty