This is the v1.0 of what will be running on the Arduinos hooked up to the photocells.
/* Arduino code for Disperse Prototype
By: Cameron Kerr
<http://www.camkerr.com>
*/
int sensorPin = 2; // select the input pin for the Photocell
int pumpPin = 13; // select the pin for the Solid State Relay and
Water Pump
int val = 0; // variable to store the value coming from the
Photocell
int count = 0; // variable to store the count that the block is
away for
void setup() {
pinMode(pumpPin, OUTPUT); // declare the pumpPin as an OUTPUT to
our Solid State relay and Water Pump
}
void loop() {
val = analogRead(sensorPin); // read the value from the photocell
if (val > 5000) // if no block is present
{
count = count + 1; // add time to the counter
}
else // if block is present
{
digitalWrite(pumpPin, HIGH); // turn the Water Pump on
delay(count); // Run the Water for the amount of
counter
digitalWrite(pumpPin, LOW); // turn the Water Pump off
count = 0; // Reset count to 0
}
}
We are meeting tomorrow to discuss aesthetics and possibly some refining of the piece as a whole. Then we build!
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment