Friday, April 16, 2010

Sensor Value

The last couple of days i have been trying to get a value work for the sensor. i have it now picking up that there is a sensor and its reading numbers 1022, 1023,1022 etc so now i need to be able to define boundaries

The following diagram is how i set it up minus the led pin


This is teh code i have so far


const int sensorPin = 0; // pin that the sensor is attached to

// variables:
int sensorValue = 0; //stores the sensor value
int sensorMin = 1023; // minimum sensor value
int sensorMax = 0; // maximum sensor value


void setup() {
// initialize serial communication:
Serial.begin(9600);
}

void loop()
{

sensorValue = analogRead(sensorPin); // stores the value of the sensore pin in Sensor Value
Serial.print(sensorValue); //Prints out the Value


delay(1000);
}

No comments:

Post a Comment