Saturday, October 22, 2011

Sensor Threshold Controlling Serial Data Sender

Suppose you only want the your remote unit in your smart system doing whatever it does when the sun is out. This could be for any reason, such as to only use power when the solar panel is charging the battery in the remote unit.

In this example I will quickly show you how you could achieve such a feat using a phototransistor and the sender/receiver system I mentioned in my second post.

Here goes;

int sensorPin = A0;
int sensorValue = 0;

void setup(){
Serial.begin(9600);
}

void loop(){
sensorValue = analogRead(sensorPin);

if (sensorValue > 200){
Serial.write('d');
delay(100);
}

}

You can see how easy it is to add layers of smarts to your system.

No comments:

Post a Comment