-1

I tried Serial.print an array I had made, but the Arduino displays nothing in the monitor.

I tried doing Serial.print("Hehehe"); as a test, but it just displayed "h?h?h?".

The monitor works fine with other sketches than this one.

Anyone knows why?

int my_array[10];

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);

  for (int i = 0; i < 10; i++){
    my_array[i] = i * 5;

  }
}

void loop() {
  // put your main code here, to run repeatedly:
    for (int i = 0; i < 10; i++){
      Serial.print(my_array[i]);
      Serial.print(" ");
    }
    Serial.println();
    delay(1000);
}
5
  • do you have 9600 baud set in Serial Monitor?
    – Juraj
    Commented Mar 10, 2020 at 18:52
  • @Juraj I have set it to 9600. Commented Mar 10, 2020 at 18:58
  • 2
    In setup() you write to undefined memory my_array[10]. It's undefined if that hurts or not. Commented Mar 10, 2020 at 19:00
  • @DataFiddler I don't quite understand. The sequence is filled in the function that takes i + 5. Commented Mar 10, 2020 at 19:14
  • i < 11 it should be 10
    – Juraj
    Commented Mar 10, 2020 at 19:37

1 Answer 1

0

Test on my Arduino Uno, your code works fine with a simple copy-paste. Remember to set the proper baud rate.

2
  • Must be something faulty with my own Arduino then. Thank you for the answer though :) Commented Mar 10, 2020 at 21:24
  • Load a blink sketch and check if the blink speed is correct. (Should have accuracy of at least 1/1000). Commented Mar 11, 2020 at 13:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.