Home \ Help \ Search \ Login RSS

Welcome, Guest. Please Login

This forum is now READ-ONLY! Please visit http://forum.wiring.co/ for the new forum.

Wiring ForumWiring HardwareTroubleshooting › multiple analog in wierd problem

Page Index Toggle Pages: 1
multiple analog in wierd problem (Read 4266 times)
05/08/08 at 15:50:00

pinareskikan   Offline
YaBB Newbies
I Love YaBB 2!

Posts: 2
*
 
We are using two basic sliders and one dimmer(rotating slider).
There are 3 values (x,y,rotation) we are reading from serial input but they are swapping.
I mean x shows y or rotation and the others are the same.
When we change the analogread ports on the code they dont change as the way we did.
We even tried to change the reading order in the code, it also masses up.
When we change the order of the ports , all 3 port values got changed.
are we missing something ?

the code is below;

Code:
int CorX;
int CorY;
int ROT;

void setup(){Serial.begin(9600);	     // sets the serial port to 9600}

void loop()
{
  delay(50);
     ROT = analogRead(0);	    // read analog input pin 0
  Serial.print(ROT, DEC);	 // prints the value read
    Serial.println("ROT ");		// prints a space betwen the numbers

   CorY = analogRead(1);	    // read analog input pin 0
  Serial.print(CorY, DEC);	 // prints the value read
  Serial.println("Y ");		// prints a space between the numbers

   CorX = analogRead(2);	    // read analog input pin 0
  Serial.print(CorX, DEC);	 // prints the value read
  Serial.println("X ");		// prints a space betwen the numbers
}
 

 
IP Logged
 
Reply #1 - 05/09/08 at 00:32:21

Alan_Kilian   Offline
Full Member
Wiring? It looks like
Java to me.

Posts: 118
***
 
I'm reading 4 potentiometers just fine, but I put a
10 millisecond delay before every analogRead() call.

Code:
int CorX;
int CorY;
int ROT;

void setup(){Serial.begin(9600);	     // sets the serial port to 9600}

void loop()
{
  delay(10);
     ROT = analogRead(0);	    // read analog input pin 0
  Serial.print(ROT, DEC);	 // prints the value read
    Serial.println("ROT ");		// prints a space betwen the numbers

  delay(10);
   CorY = analogRead(1);	    // read analog input pin 0
  Serial.print(CorY, DEC);	 // prints the value read
  Serial.println("Y ");		// prints a space between the numbers

  delay(10);
   CorX = analogRead(2);	    // read analog input pin 0
  Serial.print(CorX, DEC);	 // prints the value read
  Serial.println("X ");		// prints a space betwen the numbers

  delay(20);
}
 


 
IP Logged
 
Reply #2 - 05/13/08 at 11:01:08

pinareskikan   Offline
YaBB Newbies
I Love YaBB 2!

Posts: 2
*
 
That doesn't work  Sad
 
IP Logged
 
Reply #3 - 05/13/08 at 16:11:54

Alan_Kilian   Offline
Full Member
Wiring? It looks like
Java to me.

Posts: 118
***
 
Maybe post your code and schematic along with some output and we can take a look.
 
IP Logged
 
Page Index Toggle Pages: 1