Arduino OLED display andriod SMS

Hi,

I want to make my OLED display my SMS, the SMS send from an app, but the char include has some problem, here's my code

#include <Adafruit_ssd1306syp.h>
#define SDA_PIN 8
#define SCL_PIN 9
Adafruit_ssd1306syp display(SDA_PIN,SCL_PIN);
char message[100];
void setup()
{
  Serial.begin(57600)
  delay(1000)
  display.initialize()
}

void loop()
{
  display.message;
}

Then the error code

sketch_oct24a.ino: In function 'void setup()':
sketch_oct24a:9: error: expected `;' before 'delay'
sketch_oct24a.ino: In function 'void loop()':
sketch_oct24a:15: error: 'class Adafruit_ssd1306syp' has no member named 'message'

Thanks :slight_smile:

  Serial.begin(57600)
  delay(1000)
  display.initialize()

For a start, all of these lines should end with a semi-colon.

I am not familiar with the library but
display.message;is obviously wrong. In any case, what will the message array contain ?

Hi,UKHeliBob:)

I'm a amateur of Arduino, I want to set a global variable , when SMS receive, the android will send the SMS
through Bluetooth, then the arduino will receive the SMS and display it in OLED

Thanks

OK. Have you got any hardware and code to receive the SMS via Bluetooth on the Arduino ?
Does the Adafruit library come with any examples of how to display text on the OLED ?
Have you at least fixed the problem with the semi-colons ?

Hello again:)

Now I fix my code, it can display the variables in the monitor now, but I still don't know how to

display it in the adafruit12864 OLED, here's my now code:

#define max_char 100
char message[max_char];    // stores you message
char r_char;               // reads each character
byte index = 0;            // defines the position into your array
int i;            
#include <Adafruit_ssd1306syp.h>
#define SDA_PIN 8
#define SCL_PIN 9

Adafruit_ssd1306syp display(SDA_PIN,SCL_PIN);

void setup()
{
    Serial.begin(9600);
    delay(1000);
    display.initialize();
}

void loop()
{
     if(Serial.available()){       
        for(i=0; i<99; i++){
            message[i] = '\0';
        } 
        //resests the index        
        index=0;
    }
    //while is reading the message 
    while(Serial.available() > 0)
    {
       //the message can have up to 100 characters 
       if(index < (max_char-1)) 
       {         
           r_char = Serial.read();      // Reads a character
           message[index] = r_char;     // Stores the character in message array
           index++;                     // Increment position
           message[index] = '\0';       // Delete the last position
       }
    }
    Serial.println(message);
    display.drawLine(0, 0, 127, 63,WHITE);
    display.update();
    delay(100);
    display.clear();
    display.setTextSize(1);
    display.setTextColor(WHITE);
    display.setCursor(0,0);
    display.println(max_char);
    delay(2000);
}

Thanks again

I've not studied your code, and I'm not familiar with the libraries you are using, but

 display.println(max_char);

looks wrong - max_char is a number, shouldn't you be printing message[]? Or at least part of it?

Hi

My new code still not works, the serial monitor can display my cmd send from my android, but the OLED still
not works.

Here's the new code

String comdata = "";    
#include <Adafruit_ssd1306syp.h>
#define SDA_PIN 8
#define SCL_PIN 9

Adafruit_ssd1306syp display(SDA_PIN,SCL_PIN);

void setup()
{
    Serial.begin(9600);
    delay(1000);
    display.initialize();
}

void loop()
{
    while (Serial.available() > 0)  
    {
        comdata += char(Serial.read());
        delay(2);
    }
    if (comdata.length() > 0)
    {
        Serial.println(comdata);
        comdata = "";
    } 
    display.drawLine(0, 0, 127, 63,WHITE);
    display.update();
    delay(100);
    display.clear();
    display.setTextSize(1);
    display.setTextColor(WHITE);
    display.setCursor(0,0);
    display.println(comdata);
    delay(2000);
}

Are you seeing anything at all on the display ?

Hi

I only can see a line on the screen when the OLED initialized, then it stay there all the time
It didn't clear screen at all.
The OLED can displayed word when I quote it like ( display.println("hello, world")

Thanks

Try

String aString = "A test String";
display.println(aString);

Then try

char aCstring[] = "A test C string";
display.println(aCstring);

Do either of them put text on the screen and if so, which ?

``Hi,Bob:)

Now I fix the problem, the screen should be update every time like that

display.println(comdata);
        display.update();
        delay(2000);

Thanks!

This is my code, it works perfect:)

String comdata = "";    
#include <Adafruit_ssd1306syp.h>
#define SDA_PIN 8
#define SCL_PIN 9

Adafruit_ssd1306syp display(SDA_PIN,SCL_PIN);

void setup()
{
    Serial.begin(9600);
    delay(1000);
    display.initialize();
}

void loop()
{
    while (Serial.available() > 0)  
    {
        comdata += char(Serial.read());
        delay(2);
    }
    if (comdata.length() > 0)
    {
        Serial.println(comdata);
        display.drawLine(0, 0, 127, 63,WHITE);
        display.update();
        delay(100);
        display.clear();
        display.setTextSize(1);
        display.setTextColor(WHITE);
        display.setCursor(0,0);
        display.println(comdata);
        display.update();
        delay(2000);
        comdata = "";
    } 
}

Now who can tell me how can I change the topic to be [SOLVED]?

Glad you got it working.
You can change the Subject: when you add a reply or edit an existing one,

Thanks