29 March 2010

Task 38 - button-activated photocell (LDR) numbered output to Serial Monitor.


There's only a slight alteration to the software in Task 38.

Just means declaring
a counter variable & incrementing it whenever the button is pushed & a reading is to be outputted.

You can see (readings 9-18) where i put my finger over the photocell, & later (27-31) where i just cupped the photocell in my hand..

/* check if the pushbutton is pressed.
if it is, the buttonState is HIGH, so..*/
if (buttonState == HIGH)
{
//..increment the reading counter &..
readNum++;
//..output the LDR reading to the SM
Serial.print("Reading number ");
Serial.print(readNum); // reading count
Serial.print(" is ");
Serial.println(photocellReading); // the raw analog reading
delay(100); // debounce delay
}// if..

1 comment: