only 1V on output

I wasn’t sure if this is hardware or software error. The problem is that on digital output of my atmega1284 i only have 1V when it’s set to HIGH. I only have this problem with this code

int tlac=digitalRead(12);
int naraz=digitalRead(5);

void rovno(){
 digitalWrite(3, HIGH);
 digitalWrite(4, LOW);
 digitalWrite(6, LOW);
 digitalWrite(7, HIGH);
 Serial.println(5);
 delay(10);
}

void vzad(){
 digitalWrite(3, LOW);
 digitalWrite(4, HIGH);
 digitalWrite(6, HIGH);
 digitalWrite(7, LOW);
}

void vlavo(){
 digitalWrite(3, HIGH);
 digitalWrite(4, LOW);
 digitalWrite(6, LOW);
 digitalWrite(7, LOW);
 Serial.println(4);
 delay(10);
}

void vpravo(){
 digitalWrite(3, LOW);
 digitalWrite(4, LOW);
 digitalWrite(6, LOW);
 digitalWrite(7, HIGH);
 Serial.println(6);
 delay(10);
}

void stoj(){
 digitalWrite(3, LOW);
 digitalWrite(4, LOW);
 digitalWrite(6, LOW);
 digitalWrite(7, LOW);
}

void vlavo90(){
 digitalWrite(3, HIGH);
 digitalWrite(4, LOW);
 digitalWrite(6, HIGH);
 digitalWrite(7, LOW);
 Serial.println(3);
 delay(10);
 delay(10);
}

void vpravo90(){
  digitalWrite(3,LOW);
  digitalWrite(4,HIGH);
  digitalWrite(6,LOW);
  digitalWrite(7,HIGH);
  Serial.println(7);
  delay(10);
}

void kalibracia(){
  
}

void prekazka(){
  int s1=digitalRead(15); 
  int s2=digitalRead(16); 
  int s3=digitalRead(17); 
  int s4=digitalRead(18); 
  int s5=digitalRead(19); 
  int s6=digitalRead(20); 
  int s7=digitalRead(21); 
  int s8=digitalRead(22); 
  int s9=digitalRead(23); 
  vlavo90();
  delay(275);
  while (s1==1 || s2==1 || s3==1 || s4==1 || s5==1 || s6==1 || s7==1 || s8==1 || s9==1){
    float volts = analogRead(A0)*0.0048828125;
    float distance = 13*pow(volts, -0.9);
    if (distance < 6) {
      vlavo();
      prekazka();
    }
    if (distance > 6 && distance < 11) {
      rovno();
      prekazka();
    }
    if (distance > 11) {
      vpravo();
      prekazka();
    }
  }
}
  
void rovinka(){
  int s6a=analogRead(A2);
  int s4a=analogRead(A1);
  analogWrite(3,255);
  analogWrite(6,255);
}
  
void vlavomimo(){
  int s1=digitalRead(15); 
  int s2=digitalRead(16); 
  int s3=digitalRead(17); 
  int s4=digitalRead(18); 
  int s5=digitalRead(19); 
  int s6=digitalRead(20); 
  int s7=digitalRead(21); 
  int s8=digitalRead(22); 
  int s9=digitalRead(23); 
  while (s2==0 || s3==0 || s4==0 || s5==0 || s6==0 || s7==0 || s8==0 || s9==0){
  vlavo();
  delay(10);
  rovno();
  }
} 

void vpravomimo(){
  int s1=digitalRead(15); 
  int s2=digitalRead(16); 
  int s3=digitalRead(17); 
  int s4=digitalRead(18); 
  int s5=digitalRead(19); 
  int s6=digitalRead(20); 
  int s7=digitalRead(21); 
  int s8=digitalRead(22); 
  int s9=digitalRead(23); 
  while (s2==0 || s3==0 || s4==0 || s5==0 || s6==0 || s7==0 || s8==0 || s1==0){
  vpravo();
  delay(10);
  rovno();
  }
}

void setup(){
  while (millis() == 5000) {
    if (tlac == HIGH) kalibracia();
  }
  Serial.begin(9600);
}



void loop() {
  int s1=digitalRead(15); 
  int s2=digitalRead(16); 
  int s3=digitalRead(17); 
  int s4=digitalRead(18); 
  int s5=digitalRead(19); 
  int s6=digitalRead(20); 
  int s7=digitalRead(21); 
  int s8=digitalRead(22); 
  int s9=digitalRead(23); 
 //if (naraz==HIGH) prekazka();
 if (s5==0) rovno(); //0 cierna, 1 biela
 else { if (s4==0) vlavo();
 else { if (s6==0) vpravo();
 else { if (s3==0) vlavo();
 else { if (s7==0) vpravo();
 else { if (s2==0) vlavo90();
 else { if (s8==0) vpravo90();
 else { if (s1==0) vlavomimo();
 else { if (s9==0) vpravomimo();
}}}}}}}}}

The problem is with voids rovno, vlavo ,vpravo, vpravo90 and vlavo90. all of them are for digital pins 3,4,6,7. when i messure them with multimeter i get 1V however when there is only rovno() in void loop it is working fine. i appreciate your help.

Where do you have the equivalent of this? It’s usually in void setup():

pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);

Maybe because they are switching too fast to get a proper voltage reading. Also your missing some pinModes for those stepper pins. "hint", They go somewhere in setup().

Edit: Just saw CrossRoads post, looks like were both on the same track.

CrossRoads: Where do you have the equivalent of this? It's usually in void setup():

pinMode(3, OUTPUT); pinMode(4, OUTPUT); pinMode(6, OUTPUT); pinMode(7, OUTPUT);

thanks that was problem. I forgot something so basic :cold_sweat:

It happens. You're not the first, nor will you be the last ;) I once spent a couple hours trying to get the status light to do what I wanted - eventually realized that I also had SPI transfers going on which taken over control of D13 (SCK). Slap in the head for that one!

You have to add the pinMode() function in the setup. By defualt, if you are not going to pinMode() it, the pin would output a small voltage on its HIGH instead of 5Volts.

mixania:
You have to add the pinMode() function in the setup. By defualt, if you are not going to pinMode() it, the pin would output a small voltage on its HIGH instead of 5Volts.

No if you don’t define a pin as an output then it is an input. Then when you switch it high and low all you are doing is turning the pull up resistor on or off. As this is about 30K then any load will appear to reduce the output voltage.