Task 30:
const int buttonPin = 2;
const int LEDPin = 13;
int buttonState = 0;
void setup ()
{
pinMode (LEDPin, OUTPUT);
pinMode(buttonPin, INPUT);
}
void loop ()
{
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH)
{
digitalWrite(LEDPin, HIGH);
}
else
{
digitalWrite(LEDPin, LOW);
}
}
Task 31:
const int buttonPin = 2;
const int LEDPin = 13;
int buttonState = 0;
void setup ()
{
pinMode (LEDPin, OUTPUT);
pinMode(buttonPin, INPUT);
}
void loop ()
{
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH)
{
digitalWrite(LEDPin, LOW);
}
else
{
digitalWrite(LEDPin, HIGH);
}
}
Task 32:
const int buttonPin = 2;
const int LEDPin = 13;
int buttonState = 0;
void setup ()
{
Serial.begin(9600);
pinMode (LEDPin, OUTPUT);
pinMode(buttonPin, INPUT);
}
void loop ()
{
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH)
{
digitalWrite(LEDPin, HIGH);
Serial.println("Button Pressed - LED On");
}
else
{
digitalWrite(LEDPin, LOW);
Serial.println("Button Not Pressed - LED Off");
}
}
Monday, May 3, 2010
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment