Tuesday, February 24, 2015

En Route to Jül : Serial to OLED with Arduino

Okay, been months since I touched this stuff... and to show you how a devious mind works ..

To get the heltec.cn (huhushop) monochrome OLED working with Arduino, (Duemilanove), I had

SDA*SCL*GND*VCC = pins 5*4*GND*3V3

As mentioned here, change the 0x3D to 0x3C for the address in their code and you should see the nifty graphics. Man, thank God ISIS doesn't have access to such technology.

Then, what if you want to relay a character from the serial port to the OLED?

To get up there, first example I try is DigitalReadSerial... Hmm, if you leave Pin 2 floating, you get random stufff.. Anyways. That works..
Anyways, had to look online for some relaying code, but that's not hard - they really don't have a good thing for reading a string at a time and relaying that. At least, I don't think they do.. Shame..

Really! Try googling for "arduino string" and see what you get.

Things you find out the hard way - each time you launch the serial port monitor, you reset the Arduino.

Anyways, this is the best I could do for now. If you think of a better way, please... I know this is shabby..

Only setup and loop here, coz this is a blog.
https://learn.adafruit.com/monochrome-oled-breakouts/arduino-library-and-examples has the rest that you put before and after.. (nothing needed after, coz we're not using those bells and w functions)

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

  // by default, we'll generate the high voltage from the 3.3v line internally! (neat!)

  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  // initialize with the I2C addr 0x3D (for the 128x64)
  // init done
  
  display.clearDisplay();  // prevents adafruit logo from being displayed, but compiler is not
                          // smart enough to know that that data being loaded into the buffer is not
                          // needed and some flash space can be saved. Shame on Arduino :)
  display.display();
  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.setCursor(0,0);
  display.println("World,");

  display.display();

  delay(1000);
}

void loop() {

    char inChar;
  // read the input
  if( Serial.available()){
    delay(100);
    while( Serial.available()){
      inChar = Serial.read();
      Serial.print(inChar);
      display.print(inChar);
    }
    Serial.println();
    display.println();
    display.display();
    delay(500);
  }
}
I say shame on them for not providing a print function that also scrolls - how simple a need that is! Here's a guy ver sieht aus als sie kennt sein stuff : http://blog.oscarliang.net/arduino-oled-display-library/

No comments:

Post a Comment