pins 0 and 1 (RX, TX) stuck on HIGH(SOLVED)

Im trying to write code for a 4x4x4 LED cube iv made and im using the 1st 4 digital pins (0-3) to power on and off the LED's but the the top layers using pins 0 and 1 wont turn to LOW they stay on HIGH.
Is there somthing i should be doing before trying to use these 2 pins or?

heres the code if it helps:

int rowpins[4] = {
  0, 1, 2, 3};
int colpins[16] = {
  4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19};
int colrand = 0;
int rowrand = 0;

void setup(){
  Serial.begin(9600);
   

  for(int i = 0; i < 4; i++){
    pinMode(rowpins[i], OUTPUT);
  }
  for(int t = 0; t < 16; t++){
    pinMode(colpins[t], OUTPUT);
  }

  for(int i = 0; i < 4; i++){
    digitalWrite(rowpins[i], LOW);
  }
  for(int i = 0; i < 16; i++){
    digitalWrite(colpins[i], HIGH);
  }

}

void loop(){
  
  digitalWrite(rowpins[3], HIGH);
  digitalWrite(colpins[3], LOW);
  delay(10000);
  digitalWrite(rowpins[3], LOW);
  digitalWrite(colpins[3], HIGH);


  for(int i = 0; i < 4; i++){

    digitalWrite(rowpins[i], HIGH);

    for(int t = 0; t < 16; t++){
      digitalWrite(colpins[t], LOW);
      delay(250);
      digitalWrite(colpins[t], HIGH); 
    }
    digitalWrite(rowpins[i], LOW); 
  }
  /*
  for(int i = 0; i < 50; i++){
    colrand = random(16);
    rowrand = random(4);
    Serial.println(colrand);
    Serial.println(rowrand);
    
    digitalWrite(rowrand, HIGH);
    digitalWrite(colrand, LOW);
    delay(500);
    digitalWrite(colrand, HIGH);
    digitalWrite(rowrand, LOW);
    
  
    Serial.println(colrand);
    Serial.println(rowrand);
  
  
  }
*/


}

Do you want to use those pins for Serial communication OR for driving the LEDs. Both is the wrong answer.

1 Like

Pins 0 and 1 are used for serial communications and it's normal for them both to be a steady high when there is no actual data being sent, that is the default stop condition for serial data. It's really not possible to use pins 0 and 1 for external circuitry and still be able to utilize serial communications or to upload new sketches to the board.

Lefty

Never mind im a idiot, i forget i added that Serial.begin line for somthing else, been blind to it for hours now lol

pins 0-1 work like the rest now without it.

demonair:
So pins 0 and 1 arnt actully digital i/o pins on a arduino uno r3?

Yes they are. It's totally possible to use digitalMode(), digitalWrite(), and digitalRead() commands with pins 0 and 1 just as with any of the other avr I/O pins. However if you utilize serial commands and or expect to be able to upload sketches to the board then there is a hardware conflict in using those two pins.

I wasnt sure before i started but i looked over the specs and it said "Digital I/O Pins 14 (of which 6 provide PWM output)" so i figured pins 0 and 1 could behave the same as 2-13.

They do perform the same as any other I/O pin, but like many of the I/O pins most pins have dual capabilities to support other functions like pins 2 and 3 can be user input external interrupt pins, which means you can't use them as digital output pins at the same time if you want to use user interrupts in your sketch.

I dont want to use them for serial communications, just to set them to high and low like the others.

But your sketch code is using serial commands and has a serial.begin statement in your setup function. If you remove all the serial commands and set pins 0 and 1 to output mode and write digitalWrite(pin#,LOW) to them both they will output low levels and only output high if you command them to in your sketch. That still leaves the problem of how will you upload sketch to the board from the arduino IDE if you have stuff wired up to pins 0 and 1? You may have to temporarily remove your wires to pins 0 and 1 to upload and then reconnect them when the upload is finished.

Is there a way to set them this way or am i stuffed

Where there is a will there is a way. :wink:

Lefty

1 Like

In response to

Pins 0 and 1 are used for serial communications and it's normal for them both to be a steady high when there is no actual data being sent, that is the default stop condition for serial data. It's really not possible to use pins 0 and 1 for external circuitry and still be able to utilize serial communications or to upload new sketches to the board.

Lefty

I don't think it's normal for them to be ON when no data is being sent, at least that's not the normal operation I've seen on the UNO. I don't mean to be a stickler here, but this is the issue I'm currently having with the UNO (both of them ON with L pin 13 ON as well, the last code didn't ask for any of this behavior).

I don't think it's normal for them to be ON when no data is being sent, at least that's not the normal operation I've seen on the UNO. I don't mean to be a stickler here, but this is the issue I'm currently having with the UNO (both of them ON with L pin 13 ON as well, the last code didn't ask for any of this behavior).

Time to change your thinking. The arduino tx/rx pins operate using a TTL format. In this condition both the tx and rx pins are held high when no communication is taking place. When communication starts, the tx pin goes low also pulling the rx pin low, which is the signal to the rx device that communication is starting. Can't speak to your pin 13 issue.