SparkFun Forums 

Where electronics enthusiasts find answers.

General MicroView Support area - You have questions, find your answers here.

Moderators: marcus@geekammo, Help@GeekAmmo

By bl00p
#184909
Hello everyone,

I was just given a MicroView to play around with and I decided to build a temperature sensor. I'm using a raspberry pi to hook up the sensor too and python using pyserial to write the script to read the sensor and send it out to the MicroView. I can provide the python code if needed. My problem is with displaying it on the MicroView. My code as it stands now for some reason only displays one character at a time, for instance if the temperature is 86.1 the MicroView displays the 8 pauses then erases the 8 and displays the 6 pauses and so on and so forth. Here is the code for reference.
Code: Select all
#include <MicroView.h>

void setup() {
  uView.begin();
  uView.clear(PAGE);
  Serial.begin(9600);
}

void loop() {
  char a;
  if (Serial.available()) {
    a = Serial.read();
    uView.setFontType(1); 
    uView.setCursor(0,16);
    uView.print(a);
    uView.display();
  }
delay(2000);
}
If I remove the setCursor function, it'll display the temperature (in full) and when it loops back it'll display the next temperature reading underneath the first one and so on and so forth. I added the setCursor function because I want the temperature to display in one spot and when it loops back replace the old one with the new reading but it doesn't seem to work. Any help would be very much appreciated. Thanks!
By scotta
#184913
You're only reading one character at a time. You should change char a to a string (or array) and then use Serial.readString(), instead of Serial.read(), to get all the characters sent. Instead of Serial.readString(), you could also consider using Serial.readStringUntil() or Serial.readBytesUntil() if one of them is more suitable.

You may also wish to put a uView.clear() before the uView.setCursor() or use some other means to clear the previous reading on the display.
long long title how many chars? lets see 123 ok more? yes 60

We have created lots of YouTube videos just so you can achieve [...]

Another post test yes yes yes or no, maybe ni? :-/

The best flat phpBB theme around. Period. Fine craftmanship and [...]

Do you need a super MOD? Well here it is. chew on this

All you need is right here. Content tag, SEO, listing, Pizza and spaghetti [...]

Lasagna on me this time ok? I got plenty of cash

this should be fantastic. but what about links,images, bbcodes etc etc? [...]