Wednesday, October 7, 2009

Alysha homework 9/30

Exercise 1





Exercise 2
video



int ledPinA = 5;
int ledPinB = 6;
int ledPinC = 7;
int buttonPin = 2;
int buttonState = 0;

void setup(){
pinMode(ledPinA, OUTPUT);
pinMode(ledPinB, OUTPUT);
pinMode(ledPinC, OUTPUT);
pinMode(buttonPin, INPUT);
}

void loop(){

buttonState = digitalRead(buttonPin);

if(buttonState == HIGH) {
for(int x=0; x <10; x++){
digitalWrite(ledPinA, HIGH);
delay(100);
digitalWrite(ledPinB, HIGH);
delay(100);
digitalWrite(ledPinC, HIGH);
delay(100);
digitalWrite(ledPinA, LOW);
delay(100);
digitalWrite(ledPinB, LOW);
delay(100);
digitalWrite(ledPinC, LOW);
delay(100);
}
}
if(buttonState == LOW){
digitalWrite(ledPinA, LOW);
digitalWrite(ledPinB, LOW);
digitalWrite(ledPinC, LOW);
}

delay(1);
}






Exercise 3

video
int ledpin = 12;

int ledpin = 12;
int buttonpin = 2;

int buttonstate = 0;

void setup(){
pinMode(ledpin, OUTPUT);
pinMode(buttonpin, INPUT);
}

void loop(){

buttonstate = digitalRead(buttonpin);

if(buttonstate == HIGH) {
for(int x = 0; x<10; x++){
digitalWrite(ledpin, HIGH);
delay(500);
digitalWrite(ledpin, LOW);
delay(500);
}
}
delay(1);
}

No comments:

Post a Comment