Go Down

Topic: Arduino IDE uploads to board, but cannot open serial monitor for one sketch (Read 583 times) previous topic - next topic

nbelakovski

Normally everything works fine, but with the sketch below, I can upload it to Arduino Uno just fine, but when I click on serial monitor, I get the error:

Serial port '/dev/ttyACM0' not found. Did you select the right one from...

Here's the sketch, which reads data from a GPS device, and then stores the highest altitude it sees in an array. When it sees a higher altitude, it moves everything in the array over by 1, so it can keep track of the 10 highest altitudes registered. Then it just prints the altitude array.
Code: [Select]

#include "TinyGPS.h"
#include <NewSoftSerial.h>

TinyGPS gps;

NewSoftSerial nss(2,4,true);
int maxaltitude[10] = {0};
int testalt = 0;
char byteGPS;
int i = 0;
int j = 0;

void setup()
{
  nss.begin(4800);
  Serial.begin(115200);
  pinMode(13,OUTPUT);
}

void loop()
{
  if (nss.available())
  {
    digitalWrite(13, HIGH);
    byteGPS = nss.read();
      if (gps.encode(byteGPS))
      {
        testalt = gps.f_altitude();
      }
  if (testalt > maxaltitude[0])
  {
    i = 9;
    while (i > 0)
    {
      maxaltitude[i] = maxaltitude[i-1];
      i--;
    }
    maxaltitude[0] = testalt;
  }
  }
  Serial.println("New altitude string:");
  j = 0;
  while (j < 9)
  {
    Serial.println(maxaltitude[j]);
    j++;
  }
}


On this code, it works fine: (this code just reads data from the GPS device and prints it to the screen)
Code: [Select]

#include <NewSoftSerial.h>

NewSoftSerial nss(2,4,true);
char bytegps;

void setup()
{
  nss.begin(4800);
  Serial.begin(115200);
}

void loop()
{
  if (nss.available())
  {
    bytegps = nss.read();
    Serial.print(bytegps);
  }
}


Is it an issue with my code or is there something else going on? Thanks in advance.

Go Up