Pages: [1]   Go Down
Author Topic: only pin 13 Works  (Read 961 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 4
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i have an arduino uno. i am working on a mac. i'm trying to mess with the blinking code. first i try to change the pin number. i have tested each of the available pins (3, 5, 6, 10, and 11) it only works on 13.  i have an led light and i have put it into pin 13.  it blinks like it should. however, when i change the pin (in the code and on the arduino) it does not work. there are no error messages from the arduino program. what should i do? is there something in the code i should change or what? i am using the blinking code that came with the program, only changing the pin number.
Logged

Madison, WI
Offline Offline
Newbie
*
Karma: 0
Posts: 25
No loafing.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Post your code in code tags (it is the # sign on the message dialog).  That'll help to see what is going on.

Early thoughts though, are you setting your pins to be outputs?
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 4
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
/*
  Blink
  Turns on an LED on for one second, then off for one second, repeatedly.
 
  This example code is in the public domain.
 */

void setup() {                
  // initialize the digital pin as an output.
  // Pin 13 has an LED connected on most Arduino boards:
  pinMode(13, OUTPUT);    
}

void loop() {
  digitalWrite(13, HIGH);   // set the LED on
  delay(1000);              // wait for a second
  digitalWrite(13, LOW);    // set the LED off
  delay(1000);              // wait for a second
}
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 4
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i'm only changing the numbers right after it says pinmode
Logged

Madison, WI
Offline Offline
Newbie
*
Karma: 0
Posts: 25
No loafing.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
/*
  Blink
  Turns on an LED on for one second, then off for one second, repeatedly.

  This example code is in the public domain.
 */

void setup() {                
  // initialize the digital pin as an output.
  pinMode(12, OUTPUT);    
}

void loop() {
  digitalWrite(12, HIGH);   // set the LED on
  delay(1000);              // wait for a second
  digitalWrite(12, LOW);    // set the LED off
  delay(1000);              // wait for a second
}

That should work...if it isn't, there is something else going on that may be above my pay grade smiley-razz  

As it was pointed out, you should use a proper resistor (do a quick google search for a LED resistor calculator).  Pin -> Resistor -> Anode (long pin) -> Cathode (short pin) in GND.
« Last Edit: December 27, 2010, 08:23:42 pm by tweedius » Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 331
Posts: 16523
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Obviously, the long pin (+, anode) on the LED should go in to pin D12 and the short pin (- cathode) should go into the GND.

Are you suggesting that he not use a series current limiting resistor wired in series with the LED?

Wiring an Led directly to a output pin will burn out output pins and or leds. It will now be a problem for us to determine if he has a code problem, a wiring problem, burned out output pins, or burned out leds.

Lefty
« Last Edit: December 27, 2010, 08:17:40 pm by retrolefty » Logged

Madison, WI
Offline Offline
Newbie
*
Karma: 0
Posts: 25
No loafing.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

When I first started, I didn't, just followed Lady Ada's documentation.  But yes, that is the next step if you're brand new smiley  

http://www.ladyada.net/learn/arduino/lesson1.html

I use proper resistors on my stuff, but if you're just starting, it isn't necessarily needed for a proof that something works.  I guess I didn't think to argue with her.  And when I tried it (I held my breath) it did work.
« Last Edit: December 27, 2010, 08:21:57 pm by tweedius » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 4
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

ah ok see i didn't know that the short end of the led had to be connected to the GND pin. well that solves that thanks!
Logged

Madison, WI
Offline Offline
Newbie
*
Karma: 0
Posts: 25
No loafing.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

As retrolefty pointed out, for proper LED circuits, you should put a resistor between the Digital pin on the arduino board and the long pin of the LED.  This protects it and the arduino.

Those tutorials by Ladyada that I linked in the previous post are a good source for beginners.  It'll teach you basic circuits and basic arduino programming.
« Last Edit: December 27, 2010, 08:30:40 pm by tweedius » Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 331
Posts: 16523
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

There is a problem on that LadyAda tutorial http://www.ladyada.net/learn/arduino/lesson1.html in that it is horribly outdated and can and does lead to damaged arduino boards. The old Arduino NG board did have a series resistor between the chip and the pin 13, so you could wire just a led between pin 13 and ground without damaging the pin. However that does not apply to any of the presently available boards or even on the NG board did not apply to the other pins.

 It is a problem that keeps on returning and I'm sorry that authors don't try and make an attempt to update their content, at least those dealing with beginners tutorials.

Lefty


Logged

Madison, WI
Offline Offline
Newbie
*
Karma: 0
Posts: 25
No loafing.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

That I did not know.  I did try it on my Duemilanove when I got it about 4-5ish months ago and it worked, so I did not assume there would be a problem if it were just a test.  Seems like a dumb mistake to make/not correct?
« Last Edit: December 27, 2010, 08:54:00 pm by tweedius » Logged

Minnesota!
Offline Offline
Sr. Member
****
Karma: 0
Posts: 386
My nickname on the forum used to be Soapy29.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

A 330 ohm resister works just fine. I think the colors are red/orange, red/orange, brown, gold. I'm just going off of memory of when mine look like.
Logged

Find AKSoapy29 on:
Youtube
Website

Global Moderator
Boston area, metrowest
Online Online
Brattain Member
*****
Karma: 439
Posts: 23791
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The colors are very specific. (and generally easy to see with good lighting, unless you're partially colorblind, a fairly common male affliction. I pull out a meter to check often, the 470/560 can look very similar to me).
Black = 0
Brown = 1
Red = 2
Orange = 3
Yellow = 4
Green = 5
Blue = 6
Violet = 7
Grey = 8
White = 9

First 2 are value, third is 10s multiplier
Then gold/silver for 5%/10% tolerance

Thus, 330 is Orange-Orange-Brown (3,3 x 10^1 = 330)
May see 4 color stripes too, adds a 3rd digit before the multiplier.

If you ever order anything from www.mpja.com, the orders ship with a nice wallet size card with resister code on one side, cat 5 wiring code on the other.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Pages: [1]   Go Up
Jump to: