SO CO RRO
Me estoy volviendo LOCA, me siento súper inútil porque no se ejecuta la parte de Processing.
Quiero generar un gráfico en Processing que según la cantidad de luz que haya en la estancia este va subiendo o bajando (si incide mucha luz, el gráfico se elevaría y si la luz es muy baja, este, descendería)
Está compuesto por dos fotorresistores que son los que captarían la cantidad de luz incidente.
La parte de Arduino, está okey, se sube perfectamente, pero no se si es que no está bien linkeado el Arduino al Processing o que (por lo de que falla el Processing)
Adjunto aquí los códigos.
Perdón por esto, soy primeriza en este mundillo ![]()
ARDUINO
void setup() {
// iniciar la comunicación serial
Serial.begin (9600);
}
void loop() {
// mandar el valor of analog input 0:
Serial.println (analogRead(A0));
// esperar un poco para el analog-to-digital conversor para estabilizarse después del último
// leyendo:
Serial.println(analogRead(A1));
delay(2);
}
PROCESSING
import processing.serial.*
Serial myPort; //The serial port
int xPos = 1; // horizontal position of the graph
float inByte = 0;
void setup () {
size(1500, 500);
println(Serial.list());
myPort = new Serial(this, */dev/cu.usbmodem1201" , 9600);
// set initial background ;
background(0);
}
void draw () {
// draw the line:
stroke (80, 20, 180);
line(xPos, height, xPos, height - inByte);
// at the edge of the screen, go back to the beginning;
if (xPos >= width) {
xPos = 0;
background(0);
} else {
// increment the horizontal position:
xPos++;
}
}
void serialEvent (Serial myPort) {
// get the ASCII string:
String inString = myPort.readStringUntil('\n');
}
if (inString != null) {
// trim off any whitespace;
inString = trim(inString);
// convert to an int and map to the screen height:
inByte = float(inString)
println(inByte);
inByte = map(inByte, 0, 1023, 0, height);
}