Task 38:
const int photocellPin = 0;
const int buttonPin = 2;
int photocellReading;
int buttonState;
void setup()
{
Serial.begin(9600);
pinMode(buttonPin,INPUT);
}
void loop()
{
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH)
{
photocellReading = analogRead(photocellPin);
Serial.println(photocellReading);
delay(1000);
}
delay(250);
}
Task 39:
const int photocellPin = 0;
const int buttonPin = 2;
int photocellReading;
int buttonState;
int readCount = 0;
void setup()
{
Serial.begin(9600);
pinMode(buttonPin,INPUT);
}
void loop()
{
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH)
{
photocellReading = analogRead(photocellPin);
readCount++;
Serial.print("Reading number ");
Serial.print(readCount);
Serial.print(" is ");
Serial.println(photocellReading);
delay(1000);
}
delay(250);
}
Saturday, May 8, 2010
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment