Pages: [1]   Go Down
Author Topic: Arduino Analog values into Processing!  (Read 354 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 13
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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);                    
}

So my question is can anybody send me a code that can store 2 analog variables from arduino in processing?

I have written this processing code but I am positive that it is completely wrong haha:
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);
}

Thanks in advance!
« Last Edit: May 25, 2011, 09:15:55 pm by Siknature » Logged

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 627
Posts: 34244
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The front of this section says:-
Quote
No New Posts    Installation & Troubleshooting
For problems with Arduino itself, NOT your project
What part of "NOT your project" do you not understand?
Logged

Pages: [1]   Go Up
Jump to: