comparisons

Well, I don’t know that much c++, the last time I worked with it was over a decade ago.  So, I’m not to surprised that I get an error like this:

In function ‘void loop()’:
error: ISO C++ forbids comparison between pointer and integer

I’m trying to print my string one character at a time, and do a new line when the end of the string is hit.  Only there isn’t any easy way to find out how long an array is (that I’ve found) in this version of c++.  Eventually this will blink out morse code stuff.  As usual, I think I’m tackling the hard and lame stuff first.

/* 
   a morse code translater
   
*/

char* myStr[] = {"some string"};

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

void loop() {
  boolean isChar = true;
  int i = 0;
  while (isChar) {
    char this_char = myStr[0][i];
    if (this_char != "") {
      Serial.print(this_char);
      Serial.println(i);
      delay(300);
    }
    else
    {
      delay(1000);
      Serial.println(" ");
      isChar = false;
    }
  }
}

/*
void look_up_morse(char letter) {
  // a dash is equal to three dots
  // the space between pars of the same letter is equal to one dot
  // the space between two letters is equal to three dots
  // the space between two words is equal to seven dots
  // pause = 0 (same length as a dot)
  // short = 1 (dot)
  // long  = 2 (dash, same length as three dots)
  
  // ascii notes:
  // capitol letters are 65 (A) to 90 (Z)
  // digits are 48 (0) to 57 (9)
  A = {1, 2};
  B = {2, 1, 1, 1};
  C = {2, 1, 2, 1};
  D = {2, 1, 1};
  E = {1};
  F = {1, 1, 2, 1};
  G = {2, 2, 1};
  H = {1, 1, 1, 1};
  I = {1, 1};
  J = {1, 2, 2, 2};
  K = {2, 1, 2};
  L = {1, 2, 1, 1};
  M = {2, 2};
  N = {2, 1};
  O = {2, 2, 2};
  P = {1, 2, 2, 1};
  Q = {2, 2, 1, 2};
  R = {1, 2, 1};
  S = {1, 1, 1};
  T = {2};
  U = {1, 1, 2};
  V = {1, 1, 1, 2};
  W = {1, 2, 2};
  X = {2, 1, 1, 2};
  Y = {2, 1, 2, 2};
  Z = {2, 2, 1, 1};
  one = {1, 2, 2, 2, 2};
  two = {1, 1, 2, 2, 2};
  three = {1, 1, 1, 2, 2};
  four = {1, 1, 1, 1, 2};
  five = {1, 1, 1, 1, 1};
  size = {2, 1, 1, 1, 1};
  seven = {2, 2, 1, 1, 1};
  eight = {2, 2, 2, 1, 1};
  nine  = {2, 2, 2, 2, 1};
  zero  = {2, 2, 2, 2, 2}; 
}
*/
Advertisement

Post a Comment

Required fields are marked *
*
*

Follow

Get every new post delivered to your Inbox.