Arduino Serial Graph

Here is a simple bit of Arduino code that is handy for testing analog sensors.
It will fill the screen with a scrolling graphic representation of the sensor value. In the video that follows, an ambient light sensor (TEPT4400) in a resistive divider is displayed. After drawing the “0” it fills the remaining space with “.” such that the output is displayed in constant time. Anything faster than 38400 caused stuttering in the display from buffer overflow.

// SERIALgraph
// by krazatchu of

int sensorValue = 0;       

void setup() 

void loop() 
   sensorValue = analogRead(A0) /8;            

  for (int i=0 ; i <=  sensorValue; i++)
    Serial.print("0" );                       

  for (int i= sensorValue; i <=  128; i++)
    Serial.print("." );                       
  Serial.println(" ");


One Response to “Arduino Serial Graph

Leave a Reply

Your email address will not be published. Required fields are marked *