SparkFun Forums 

Where electronics enthusiasts find answers.

Your source for all things Atmel.
By Wallen
#43810
Hi all,

So I'm making some headway learning about this DX160.

Everything seems to be working. But when I send a second update to the screen - it just blanks out and seems to die. Not sure if this is my code or what.

It also does then when I try to change my font size. Argh, I wish there was more documentation :)

Any help would be greatly appreciated!
Code: Select all
char incomingByte;  // Serial communication
char tmpOutput[200]; // Store incoming serial communication
char *cursor;
char *str = "";
int count = 0;
int speaker = 9;
int led = 13;
int btn = 10;

void setup() {
  pinMode(speaker, OUTPUT);
  pinMode(led, OUTPUT);
  Serial.begin(57600);
  digitalWrite(led, HIGH);
}

void loop() {
  if (Serial.available() > 0) {
    if (incomingByte != 13) {
      incomingByte = Serial.read();
      tmpOutput[count] = incomingByte;
      count++;
    }
    
    if (incomingByte == 13) {
      clearDisplay();
      say(tmpOutput);
      Serial.print(255, BYTE);delay(10);
      count=0;
      
      delay(2000);
    }
  }
}


void clearDisplay() {
  Serial.print(186, BYTE);
  delay(100);
}

void say(char* text) {
  for(cursor=text; *cursor != '\0'; ++cursor) {
    Serial.print(*cursor, BYTE);
  }
}


void setSmallFont() {
  Serial.print(181, BYTE);
  delay(10);
}

void setLargeFont() {
  Serial.print(180, BYTE);
  delay(10);
}