GMU:Tutorials/Performance Platform/Controlling an Arduino with The Captury: Difference between revisions
From Medien Wiki
Line 73: | Line 73: | ||
<br style="clear:both"> | <br style="clear:both"> | ||
'''The Code Using Photocell:''' | |||
<source lang="Java" line start= "1"> | |||
int photocellPin = 0; // the cell and 10K pulldown are connected to A0 | |||
int photocellPin1 = 1; // the cell and 10K pulldown are connected to A1 | |||
int photocellReading, photocellReading1; // the analog reading from the sensor divider | |||
void setup() { // We'll send debugging information via the Serial monitor | |||
Serial.begin(9600); | |||
pinMode(3, OUTPUT); | |||
pinMode(5, OUTPUT); | |||
} | |||
void loop(void) { | |||
photocellReading = analogRead(photocellPin); | |||
photocellReading1 = analogRead(photocellPin1); | |||
if(photocellReading < 400 && photocellReading1 < 400 ){ | |||
digitalWrite(3, HIGH); | |||
digitalWrite(5, HIGH); | |||
delay(100); | |||
} | |||
else { | |||
digitalWrite(3, LOW); | |||
digitalWrite(5, LOW); | |||
delay(100); | |||
} | |||
Serial.print("Analog reading1 = "); | |||
Serial.println(photocellReading); // the raw analog reading1 | |||
Serial.print("Analog reading2 = "); | |||
Serial.println(photocellReading1); // the raw analog reading2 | |||
Serial.println(" "); | |||
delay(10); | |||
} | |||
</source> | |||
== Second Part == | == Second Part == |