Hey I'm trying to read a voltage on any of the analog pins on the teensy 3.0
I have a voltage of say 2.45V at the pin from a sensor.
If I connect the A1 pin to the sensor signal
and A2 to the sensor ground A1=1024; and A2=0;
I am only able to get 1024 or 0 no mater what the voltage. At first my sensor was scaled to have a max signal voltage of 5volts..
I thought I saturated the pin.. maybe it was running at 3.3... so I scaled down my sensor max voltage.
Im reading two AD590 sensors
12V supply to the sensors, 25kohm sensing resistor to ground. I had a more complex version of the code working fine on an arduino. Is there something I have to do to set the pin??
I have seen a couple ways to do this.
------------------------------------
int analog1Pin = 1;
pinMode(analog1Pin,INPUT);
------------------------------------
int analog1Pin;
anaog1Pin=analogRead(1);
------------------------------------
Whats the difference?!
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
void setup()
{
Serial.begin(9600);
}
int val1;
int val2;
int val3;
int val4;
int val5;
float temp1;
float temp2;
float sensorV1max=3.264;
float sensorV2max=3.32;
float maxT=350;
void loop()
{
val1 = analogRead(1);
val2 = analogRead(2);
val3 = analogRead(3);
val4 = analogRead(4);
val5 = analogRead(5);
temp1=(((5*(val1-val2)/1024))/sensorV1max)*maxT;
temp2=(((5*(val3-val4)/1024))/sensorV2max)*maxT;
Serial.print("analog 1 is: ");
Serial.println(val1);
Serial.print("analog 2 is: ");
Serial.println(val2);
Serial.print("analog 3 is: ");
Serial.println(val3);
Serial.print("analog 4 is: ");
Serial.println(val4);
Serial.print("analog 5 is: ");
Serial.println(val5);
Serial.println(" ");
Serial.print("Temp1: ");
Serial.println(temp1);
Serial.print("Temp2: ");
Serial.println(temp2);
Serial.println(" ");
delay(250);
}
I have a voltage of say 2.45V at the pin from a sensor.
If I connect the A1 pin to the sensor signal
and A2 to the sensor ground A1=1024; and A2=0;
I am only able to get 1024 or 0 no mater what the voltage. At first my sensor was scaled to have a max signal voltage of 5volts..
I thought I saturated the pin.. maybe it was running at 3.3... so I scaled down my sensor max voltage.
Im reading two AD590 sensors
12V supply to the sensors, 25kohm sensing resistor to ground. I had a more complex version of the code working fine on an arduino. Is there something I have to do to set the pin??
I have seen a couple ways to do this.
------------------------------------
int analog1Pin = 1;
pinMode(analog1Pin,INPUT);
------------------------------------
int analog1Pin;
anaog1Pin=analogRead(1);
------------------------------------
Whats the difference?!
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
void setup()
{
Serial.begin(9600);
}
int val1;
int val2;
int val3;
int val4;
int val5;
float temp1;
float temp2;
float sensorV1max=3.264;
float sensorV2max=3.32;
float maxT=350;
void loop()
{
val1 = analogRead(1);
val2 = analogRead(2);
val3 = analogRead(3);
val4 = analogRead(4);
val5 = analogRead(5);
temp1=(((5*(val1-val2)/1024))/sensorV1max)*maxT;
temp2=(((5*(val3-val4)/1024))/sensorV2max)*maxT;
Serial.print("analog 1 is: ");
Serial.println(val1);
Serial.print("analog 2 is: ");
Serial.println(val2);
Serial.print("analog 3 is: ");
Serial.println(val3);
Serial.print("analog 4 is: ");
Serial.println(val4);
Serial.print("analog 5 is: ");
Serial.println(val5);
Serial.println(" ");
Serial.print("Temp1: ");
Serial.println(temp1);
Serial.print("Temp2: ");
Serial.println(temp2);
Serial.println(" ");
delay(250);
}