Serial.print not working

hi all

for some reason my Serial print isn’t working at all

there are no errors or mistakes i can see but i’m very now so i’m probably missing some thing obvious

int ledpinr = 5;
int ledping = 6;
int ledpinb = 7;
int trigPin1 = 8;
int echoPin1 = 9;
int red = 255;
int blue = 255;
int green = 255;
int val;
boolean busy = false;
long duration1, distance1;
void setup() {
  pinMode(trigPin1, OUTPUT);
  pinMode(echoPin1, INPUT);
  Serial.begin(9600);
  led_update();

}
void loop() {}

void led_update()
{
  //Set PWM on pins 9 10 and 11
  analogWrite(ledpinr, red);
  analogWrite(ledping, green);
  analogWrite(ledpinb, blue);
  //delay(500);
}
void color_morph(int* value, int maxval, int get_brighter)
{
  if (maxval > 255) {
    maxval = 255;
  }
  else if (maxval < 0) {
    maxval = 0;
  }
  for (int i = 0; i < maxval; i++)
  {
    if (get_brighter) {
      if (*value > 0) {
        (*value)--;
      }
    }
    else {
      if (*value < 255) {
        (*value)++;
      }
    }
  }
  led_update();
  delay(5);
  digitalWrite(trigPin1, LOW);

  delayMicroseconds(2);

  digitalWrite(trigPin1, HIGH);

  delayMicroseconds(10);

  digitalWrite(trigPin1, LOW);

  duration1 = pulseIn(echoPin1, HIGH);

  distance1 = (duration1 / 2) / 29.1;

Serial.print(distance1);

Serial.println("cm");

  delay(500); 
}

Hi,
How are you going to access the functions with the Serial.print statments if you don’t call them in your void loop()

void loop() {}

Nothing is being done.

void color_morph(int* value, int maxval, int get_brighter)
{
  if (maxval > 255) {
    maxval = 255;
  }
  else if (maxval < 0) {
    maxval = 0;
  }
  for (int i = 0; i < maxval; i++)
  {
    if (get_brighter) {
      if (*value > 0) {
        (*value)--;
      }
    }
    else {
      if (*value < 255) {
        (*value)++;
      }
    }
  }
  led_update();
  delay(5);
  digitalWrite(trigPin1, LOW);

  delayMicroseconds(2);

  digitalWrite(trigPin1, HIGH);

  delayMicroseconds(10);

  digitalWrite(trigPin1, LOW);

  duration1 = pulseIn(echoPin1, HIGH);

  distance1 = (duration1 / 2) / 29.1;

Serial.print(distance1);

Serial.println("cm");

  delay(500); 
}

Here are your Serial.print , but you are not using the function.

The code runs

void setup()
{
}
void loop()
{
}

You have to include the function calls yourself in setup or loop.
Just because you code the functions after the void loop() does not mean they are used.

Tom… :slight_smile:

And … a tip is to ‘serial print (“Go!”);’ just after the serial begin statement. - then you know it’s working and later problems are your fault !!

Don’t forget you can print things as a debugging tool “ program is here” etc