arduino + processing help me plz
in
Integration and Hardware
•
1 month ago
hi , i have a problem plz help
me, how can i read many data of arduino on processing D: ??
plz help mee :(
arduino code :
#include "DHT.h"
#define DHTPIN 7
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
int val = 0 ;
int val2 = 0 ;
void setup() {
Serial.begin(9600);
dht.begin();
}
void loop() {
int h = dht.readHumidity();
int t = dht.readTemperature();
val = h ;
val2 = t ;
Serial.write('h');
Serial.write(val);
Serial.write('t');
Serial.write(val2);
}
processing code :
import processing.serial.*;
Serial port;
PFont text;
int val;
void setup (){
size(500,500);
smooth();
text = loadFont("AgencyFB-Reg-48.vlw");
println(Serial.list());
port = new Serial(this,Serial.list()[1],9600);
textFont(text);
textSize(60);
}
void draw() {
background(0);
if(port.available() > 0 ){
val = port.read() ;
switch(val){
case 'h' :
val = port.read() ;
fill(#03F4FF);
text("HUMIDITY : "+ val + " %",50,300);
break;
case 't' :
val = port.read() ;
fill(#FF0303);
text("TEMPERATURE : " + val + " °C",50,125);
break;
}
}
1