Arduino to Processing Question
in
Integration and Hardware
•
2 years ago
Im doing a project at the moment where i am using flex sensors to measure texture. These flex sensors are read by arduino as analog values. These values I want to be sent to processing. I have downloaded the Serial library for processing to do this. BUt despite researching all day I haven't been able to find a way to store the readings from the flex sensors into a variable in processing.
Here is my arduino code:
Here is my arduino code:
const int analogInPin = A0;
const int analogInPin2 = A5;
const int analogOutPin = 9;
const int analogOutPin2 = 9;
int sensorValue = 0;
int sensorValue2 = 0;
int outputValue = 0;
int outputValue2 = 0;
void setup() {
Serial.begin(9600);
}
void loop() {
// read the analog in value:
sensorValue = analogRead(analogInPin);
sensorValue2 = analogRead(analogInPin2);
outputValue = map(sensorValue, 0, 1023, 0, 255);
outputValue2 = map(sensorValue2, 0, 1023, 0, 255);
analogWrite(analogOutPin, outputValue);
analogWrite(analogOutPin2, outputValue2);
Serial.print("\t output A0= ");
Serial.println(outputValue);
delay(10);
Serial.print("\t output A5= ");
Serial.println(outputValue2);
delay(10);
}
And here is some processing code that I wrote but im pretty sure its 100% wrong, it was just a wild stab:
So my question is can anybody send me a code that can store 2 analog variables from arduino in processing?
Thanks in advance!
And here is some processing code that I wrote but im pretty sure its 100% wrong, it was just a wild stab:
import processing.serial.*;
import cc.arduino.*;
Arduino arduino;
float myValue;
float myValue2;
void setup()
{
println(Arduino.list());
arduino = new Arduino(this, Arduino.list()[0], 9600);
}
void draw()
{
myValue = arduino.analogRead(0);
println(myValue);
myValue2 = arduino.analogRead(5);
println(myValue2);
}
So my question is can anybody send me a code that can store 2 analog variables from arduino in processing?
Thanks in advance!
1