#include "mbed.h"
#include "Terminal.h" //header file for terminal screen
Terminal term(USBTX, USBRX); //setup USB interface to host terminal
AnalogIn mypot(p20); //Assign mypot to analog input on pin20
float array1[100];
float x, y;
float sum;
int q, r;
int main()
{
while(1)
{
x=mypot.read(); //reads value of pot
//**************Raw value section of program to show value is correct*****************
//term.printf(" Raw Value = ð.2\n ",x*3.3);
//Add together 10 values from piezo sensor
for ( q=0; q<99; q++);
{
array1[q]=x;
//wait(0.1);
}
sum=0;
for (r=0;r<=99;r++)
{
sum = sum+array1[r];
}
sum=sum/100;
y=sum*3.3;
x=x*100;
term.printf(" Raw Value = ð.2 Value 1 = ð.2\r ",x,y); //print value on teraterm
//wait (0.2); //wait 0.2 seconds between samples
term.cls();
}
}
Lowercase for the code tags fixes it :)
Regarding your problem, increasing baudrate might help, also clearing the screen directly in front of the printf will help a bit. (especially with some delay, there is really not much point in updating it faster than you can read it). I never actually used the terminal library myself, I always simply use serial and not the extra terminal functions. But you can try using the locate function instead of cls, so it would overwrite the old printf instead of clearing the entire screen. Even better, it then isnt required to rewrite stuff like "Raw value", but you only need to overwrite the actual data.
Hi all, I've been asking a few questions on here but i have one i'm sure many will know how to solve. I have a simple program which puts a value obtained into teraterm. The problem is the cycle of reading it, putting it on the screen in teraterm, and then refreshing causes it to 'flicker' and any changes in the values are difficult to see. The device is working in real time so the values are updating as quickly as the microprocessor can do it. I was wondering if someone could tell me how to get the values showing on the screen nice and cleanly and solid.
I've attached the progam to look at.
Many Thanks Rob
/media/uploads/robert111/aaapiezo_test_1_lpc11u24.bin