Pages: [1] 2   Go Down
Author Topic: Can't write multiple pins HIGH why?  (Read 1346 times)
0 Members and 1 Guest are viewing this topic.
Gales Ferry, CT
Offline Offline
Newbie
*
Karma: 0
Posts: 35
Always thinking
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Here is my code:

Code:
int ledI = 13;
int ledL = 12;
int ledO = 11;
int ledV = 10;
int ledE = 9;
int ledY = 8;
int ledo = 7;
int ledU = 6;

void setup() {               
 
  pinMode(ledI, OUTPUT); 
  pinMode(ledL, OUTPUT);
  pinMode(ledO, OUTPUT);
  pinMode(ledV, OUTPUT);
  pinMode(ledE, OUTPUT);
  pinMode(ledY, OUTPUT);
  pinMode(ledo, OUTPUT);
  pinMode(ledU, OUTPUT);
}

// the loop routine runs over and over again forever:
void loop() {
  delay(100);
  digitalWrite(ledI, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);               // wait for a second
  digitalWrite(ledI, LOW);    // turn the LED off by making the voltage LOW
  delay(3000);               // wait for a second
  digitalWrite(ledL, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);               // wait for a second
  digitalWrite(ledL, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);               // wait for a second
  digitalWrite(ledO, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(3000);               // wait for a second
  digitalWrite(ledO, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);               // wait for a second
  digitalWrite(ledV, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(3000);               // wait for a second
  digitalWrite(ledV, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);               // wait for a second
  digitalWrite(ledE, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(3000);               // wait for a second
  digitalWrite(ledE, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);               // wait for a second
  digitalWrite(ledY, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(3000);               // wait for a second
  digitalWrite(ledY, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);               // wait for a second
  digitalWrite(ledo, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(3000);               // wait for a second
  digitalWrite(ledo, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);               // wait for a second
  digitalWrite(ledU, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(3000);               // wait for a second
  digitalWrite(ledU, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);               // wait for a second
}

I then wanted the led I, L, O, V, E, Y, o, U to write high and tried to use digitalWrite but it errored on me. What should I use in its place?

Thanks
Logged

Patience.....

Grand Blanc, MI, USA
Offline Offline
Faraday Member
**
Karma: 71
Posts: 3512
CODE is a mass noun and should not be used in the plural or with an indefinite article.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I then wanted the led I, L, O, V, E, Y, o, U to write high and tried to use digitalWrite but it errored on me. What should I use in its place?

What is the error? It compiles fine for me.
Logged

MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 549
Posts: 46109
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
What should I use in its place?
Your wife/girlfriend/whatever is going to fall asleep waiting for the end of that cycle. Why such a long delay between changes?
Logged

Grand Blanc, MI, USA
Offline Offline
Faraday Member
**
Karma: 71
Posts: 3512
CODE is a mass noun and should not be used in the plural or with an indefinite article.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
What should I use in its place?
Your wife/girlfriend/whatever is going to fall asleep waiting for the end of that cycle. Why such a long delay between changes?

Perhaps the focus is not completely on the microcontroller, between delays.
Logged

MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

Offline Offline
God Member
*****
Karma: 27
Posts: 829
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Unless there is a typo I am missing, your code should run fine. I agree though, your delays are really long. lol.

Did you really intend it to take 30 seconds to cycle through one loop?
Logged

Gales Ferry, CT
Offline Offline
Newbie
*
Karma: 0
Posts: 35
Always thinking
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey the delay is just the default blink I was going to slim it down but was halted in the code development! My wife would fall asleep LOL

The last two lines is what I was having issues with. Dunno why I didn't copy them in first!


Code:
int ledI = 13;
int ledL = 12;
int ledO = 11;
int ledV = 10;
int ledE = 9;
int ledY = 8;
int ledo = 7;
int ledU = 6;

void setup() {               
 
  pinMode(ledI, OUTPUT); 
  pinMode(ledL, OUTPUT);
  pinMode(ledO, OUTPUT);
  pinMode(ledV, OUTPUT);
  pinMode(ledE, OUTPUT);
  pinMode(ledY, OUTPUT);
  pinMode(ledo, OUTPUT);
  pinMode(ledU, OUTPUT);
}

// the loop routine runs over and over again forever:
void loop() {
  delay(100);
  digitalWrite(ledI, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);               // wait for a second
  digitalWrite(ledI, LOW);    // turn the LED off by making the voltage LOW
  delay(3000);               // wait for a second
  digitalWrite(ledL, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);               // wait for a second
  digitalWrite(ledL, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);               // wait for a second
  digitalWrite(ledO, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(3000);               // wait for a second
  digitalWrite(ledO, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);               // wait for a second
  digitalWrite(ledV, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(3000);               // wait for a second
  digitalWrite(ledV, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);               // wait for a second
  digitalWrite(ledE, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(3000);               // wait for a second
  digitalWrite(ledE, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);               // wait for a second
  digitalWrite(ledY, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(3000);               // wait for a second
  digitalWrite(ledY, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);               // wait for a second
  digitalWrite(ledo, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(3000);               // wait for a second
  digitalWrite(ledo, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);               // wait for a second
  digitalWrite(ledU, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(3000);               // wait for a second
  digitalWrite(ledU, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);               // wait for a second
  digitalWrite(ledI, ledL, ledO, ledV, ledE, ledY, ledo, ledU, HIGH);    // turn the LED off by making the voltage LOW
  delay(1000);               // wait for a second
  digitalWrite(ledI, ledL, ledO, ledV, ledE, ledY, ledo, ledU, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);               // wait for a second
}
Logged

Patience.....

Offline Offline
God Member
*****
Karma: 27
Posts: 829
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ahhh... lol. Yeah, you can't do that. Just put each one on it's own line without any delays in between. It will happen so fast, that it will appear to all turn on at once. The human eye couldn't capture it.

Also, if they are all using the 8 bits (you have 8 letters) of one port, you could just do this:

PORTn = 0xFF and that would turn on all bits at once. n = whatever port they are on. PORTD is pins 0-7. But you will lose your serial port. If you aren't using it, no big deal. It's the only full 8-bit port available.

However, my first suggestion would happen so fast, the results will look the same.
« Last Edit: February 11, 2013, 08:45:32 pm by Retroplayer » Logged

Gales Ferry, CT
Offline Offline
Newbie
*
Karma: 0
Posts: 35
Always thinking
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Awesome thanks!  smiley-eek
Logged

Patience.....

Gales Ferry, CT
Offline Offline
Newbie
*
Karma: 0
Posts: 35
Always thinking
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Retro

I deleted all delays and it blinked for a tiny fraction of a second but was almost unnoticeable so I deleted the delay after the low and it blinks left to right really fast which is not what I want. Thoughts?

Code:
int ledI = 13;
int ledL = 12;
int ledO = 11;
int ledV = 10;
int ledE = 9;
int ledY = 8;
int ledo = 7;
int ledU = 6;

void setup() {               
 
  pinMode(ledI, OUTPUT); 
  pinMode(ledL, OUTPUT);
  pinMode(ledO, OUTPUT);
  pinMode(ledV, OUTPUT);
  pinMode(ledE, OUTPUT);
  pinMode(ledY, OUTPUT);
  pinMode(ledo, OUTPUT);
  pinMode(ledU, OUTPUT);
}

// the loop routine runs over and over again forever:
void loop() {
  delay(1000);
  digitalWrite(ledI, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(500);               // wait for a second
  digitalWrite(ledI, LOW);    // turn the LED off by making the voltage LOW
  delay(500);               // wait for a second
  digitalWrite(ledL, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(500);               // wait for a second
  digitalWrite(ledL, LOW);    // turn the LED off by making the voltage LOW
  delay(500);               // wait for a second
  digitalWrite(ledO, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(500);               // wait for a second
  digitalWrite(ledO, LOW);    // turn the LED off by making the voltage LOW
  delay(500);               // wait for a second
  digitalWrite(ledV, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(500);               // wait for a second
  digitalWrite(ledV, LOW);    // turn the LED off by making the voltage LOW
  delay(500);               // wait for a second
  digitalWrite(ledE, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(500);               // wait for a second
  digitalWrite(ledE, LOW);    // turn the LED off by making the voltage LOW
  delay(500);               // wait for a second
  digitalWrite(ledY, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(500);               // wait for a second
  digitalWrite(ledY, LOW);    // turn the LED off by making the voltage LOW
  delay(500);               // wait for a second
  digitalWrite(ledo, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(500);               // wait for a second
  digitalWrite(ledo, LOW);    // turn the LED off by making the voltage LOW
  delay(500);               // wait for a second
  digitalWrite(ledU, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(500);               // wait for a second
  digitalWrite(ledU, LOW);    // turn the LED off by making the voltage LOW
  delay(500);               // wait for a second
  digitalWrite(ledI, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(50);
  digitalWrite(ledI, LOW);    // turn the LED off by making the voltage LOW
 
  digitalWrite(ledL, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(50);
  digitalWrite(ledL, LOW);    // turn the LED off by making the voltage LOW
 
  digitalWrite(ledO, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(50);
  digitalWrite(ledO, LOW);    // turn the LED off by making the voltage LOW

  digitalWrite(ledV, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(50);
  digitalWrite(ledV, LOW);    // turn the LED off by making the voltage LOW

  digitalWrite(ledE, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(50);
  digitalWrite(ledE, LOW);    // turn the LED off by making the voltage LOW
 
  digitalWrite(ledY, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(50);
  digitalWrite(ledY, LOW);    // turn the LED off by making the voltage LOW
 
  digitalWrite(ledo, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(50);
  digitalWrite(ledo, LOW);    // turn the LED off by making the voltage LOW
 
  digitalWrite(ledU, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(50);
  digitalWrite(ledU, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);
}
Logged

Patience.....

Lost Wages
Offline Offline
Full Member
***
Karma: 11
Posts: 103
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm going to take a wild guess.

Each pin has multiple LEDs on it that spell out each letter?

Remember that the Arduino pins are only rated for 40mA max.  If you are trying to drive a number of LEDs in parallel then your poor Arduino just can't keep up.  If you are driving them in series, then the voltage across the string would have to be much larger than 5V.

If, indeed, the LEDs are in parallel be sure that each LED has its own individual current-limiting resistor and place an NPN transistor from ground to the cathodes of the LEDs and then place the current-limiting resistors from the anode to +5V.  Use a 10k resistor from the each Arduino pin to the base of each transistor.

With 330 ohm resistors, each LED will draw about 10mA.  So a 2n2222 should be fine. It has a max current of 200mA so it would drive 20 LEDs.

I hope that this helps but it is a wild guess.



* led_driver.jpg (12.65 KB, 393x270 - viewed 20 times.)
« Last Edit: February 11, 2013, 09:13:26 pm by MaJiG » Logged

Gales Ferry, CT
Offline Offline
Newbie
*
Karma: 0
Posts: 35
Always thinking
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I put one LED to one pin.

https://docs.google.com/file/d/0Bx_sFejXsULPZm9BMFloRW5UWjQ/edit?usp=sharing
Logged

Patience.....

Lost Wages
Offline Offline
Full Member
***
Karma: 11
Posts: 103
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Your resistors are not in the breadboard correctly.

From the Arduino pin to one end of the resistor
The other end should be in another row, with the (looks like) anodode of the LED
The other end of the LED should go to ground

These LEDs are probably burned, so try new ones
Logged

Gales Ferry, CT
Offline Offline
Newbie
*
Karma: 0
Posts: 35
Always thinking
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The LED's are working just fine what did I do?!  smiley-money
Logged

Patience.....

Lost Wages
Offline Offline
Full Member
***
Karma: 11
Posts: 103
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If you move each wire from an Arduino pin one breadboard row to the left and the move the near end of the resistor over to the row with the wire, you'll be gold.  Of course the left-most will need a custom swap, but you get the idea...
Logged

Gales Ferry, CT
Offline Offline
Newbie
*
Karma: 0
Posts: 35
Always thinking
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok I see what I did... put each resistor on the same line as the led so essentially muting the resistor. This correct?  smiley-eek-blue
Logged

Patience.....

Pages: [1] 2   Go Up
Jump to: