Hi, I have a very simple program made with a Nano Arduino and a humidity sensor.
The sensor obtains a data per second and shows it in the serial port with two values, the first with values from zero to 1023 of the sensor and the second in percentages, separated both values by a space.
I put the Arduino sketch:
//*Sensor de humedad, Arduino Nano.
//*Por Puerto serie arroja el valor de la conductividad, luego un espacio vacío y
//*luego el valor porcentual
#include <Wire.h>
const int sensorPin = A0; //Sensor de humedad
unsigned long humedad, Porcentaje = 0; //Valor de humedad y su porcentaje
void setup ()
{
Serial.begin(115200); //Inicia el puerto serie
}
void loop ()
{
humedad = 1023 - analogRead(sensorPin); //Invertir el valor (resistencia a conductancia)
//humedad = humedad * log(3);
Serial.print(humedad); //Muestra el valor de conductancia
Serial.print(" "); //Un espacio en blanco
Porcentaje = humedad * 100 / 1023; //Cálculo porcentual
Serial.println(Porcentaje); //Muestra el porcentaje
//Serial.println();
delay(1000);
}
As an introduction I will say that with processing I want to make several windows to graph the data in different ways, a window with the digital data list. Another with a graph of lines with the evolution of the data and another with a bar graph where the bar goes “going up and down” according to the value of the conductance and at the same time changing color.
For now the problem is that I made the digital data window, which shows the date and time but I want to make a list, and what it does right now is to show the date and time data always on the same line , I do not know what commands I need to show all the values listed and then make a scrolling when get to the end of the window.
The processing IDE Sketch:
PImage img;
void setup()
{
size(640,480);// creamos la ventana
textSize(20);// definimos el tamaño de la letra
img = loadImage("Logo_Digital.jpg");
}
void draw()
{
background(300);
int y = 20;
image(img,520, 10);
int Anio = year(); // Valores de 2015, 2014, etc
int Mes = month(); // Valores de 1 a 12
int Dia = day(); // Valores de 1 a 31
fill(255,0,0);
int Segundos = second(); // Valores de 0 a 59
int Minutos = minute(); // Valores de 0 a 59
int Hora = hour(); // Valores de 0 a 23
text(Dia + "/" + Mes + "/" + Anio + " " +
Hora + ":" + Minutos + ":" + Segundos, 10, y);
}