How to update every 10 millisecond as opposed to every second

[code]Hello,

I have been working on this library called Brain library and trying to visualise the values coming every second. But it makes my visual blink every second, i want it to run smooth, maybe update it every 1/10th second (to make it not blink but a smooth transition).

Here`s the arduino code:
[code]
#include <Brain.h>

// Set up the brain parser, pass0 it the hardware serial object you want to listen on.
Brain brain(Serial1);

void setup() {
	// Start the hardware serial.
	Serial1.begin(9600);    //moved from brain (init)
     Serial.begin(9600);
     Serial.println("ready");
}

void loop() {
	// Expect packets about once per second.
	// The .readCSV() function returns a string (well, char*) listing the most recent brain data, in the following format:
	// "signal strength, attention, meditation, delta, theta, low alpha, high alpha, low beta, high beta, low gamma, high gamma"	
	if (brain.update()) {
  		Serial.println(brain.readErrors());
		Serial.println(brain.readCSV());
	}
}

And here`s the processing code:

import processing.serial.*;

Serial myPort;

int channels = 10;
int [] channel = new int[channels];
int packetCount = 0;
long startMillis = System.currentTimeMillis();
//float easing=1;
//int last;
//int millis();


void setup() {
  size(800, 800);
  println(Serial.list());
  String portName= Serial.list() [0];
  myPort= new Serial(this, portName, 9600);
  myPort.bufferUntil(10);
  background(0);
  smooth();
  noFill();
  stroke(160);
  frameRate(60);
}

void draw() {
  /*
  if(channel.length>3) {
   for (int i=3; i<channel.length; i++) {
   ellipse(400,300, channel[i], channel[i]);
   
   }
   }*/ 

}

void serialEvent (Serial myPort) {
  background(0);

  String[] incomingValues = split(myPort.readString(), ',');

  if (incomingValues.length>1) {
    packetCount++;
    println(incomingValues[1]);
    
    if (incomingValues.length>1)
    {
      stroke(255);
      int amplitude1 = 100-Integer.parseInt(incomingValues[1].trim());
      
//      last=millis();
      float y = 0;
      float prevY = 0;


      for (int i = 1; i < width; i++)
      {
//        amplitude= amplitude*millis();
        y = sin(radians(i*2))*amplitude1;
        line(i-1, prevY+height/2, i, y+height/2);
        
        prevY = y*200;
    
    }
  }
}  
}

Here a sine wave is drawn, but it updates every second and as i said it blinks. I dont want that but make it more smooth transition, how can i do it? PLease help…It would be really appreciated. Thanks again :)[/code][/code]

Read the sticky at the top of this forum on how to post.

Sorry! But now can you help? Would millis() function help and if yes, then how?

Thanks

tashing: I have been working on this library called Brain library and trying to visualise the values coming every second. But it makes my visual blink every second, i want it to run smooth, maybe update it every 1/10th second (to make it not blink but a smooth transition).

(snip)

Here a sine wave is drawn, but it updates every second and as i said it blinks. I dont want that but make it more smooth transition, how can i do it? PLease help..It would be really appreciated. Thanks again :)

I don't see anything to control the update interval so I guess it is governed by how long Brain.update() takes to complete, or how often it returns a true value. How does that work? Is it dependent on input on Serial1? Where does that input come from?

I have no idea whether the update rate is causing the flickering in Processing, though. Is your Processing code based on any examples, and do those examples also flicker?