Tuesday, October 6, 2009

Quasi- Code

The button pin is number one. The led pin is number 12. When the button is pressed the 
led turns on. There is a twenty milisecond delay. If the button is pressed for more time 
than the debounce time, then it reads the actual state of the button.  (This was confusing)

Andrew Zahn CODE 3 VIDEO

Andrew Zahn CODE 2 VIDEO

Andrew Zahn CODE 1 VIDEO

Andrew Zahn CODE 3.

int timer = 50;
int ledPin = 3;
int i = 0;
void setup() {
  Serial.begin(9600);
  pinMode(ledPin, OUTPUT);
}

void loop() {
  
  for (int i = 0; i <>
  digitalWrite(ledPin, HIGH);
  delay(i);
  digitalWrite(ledPin, LOW);
  delay(i);
  Serial.println(i);
  }
}
  

Andrew Zahn CODE 2.

int timer = 100;         

void setup() {

  for (int thisPin = 2; thisPin <>
    pinMode(thisPin, OUTPUT);      
  }
}

void loop() {
  
  for (int thisPin = 0; thisPin <>
    
    digitalWrite(thisPin, HIGH);   
    delay(timer);                  
    
    digitalWrite(thisPin, LOW);    
  }

  
  for (int thisPin = 7; thisPin >= 2; thisPin--) { 
   
    digitalWrite(thisPin, HIGH);
    delay(timer);

    digitalWrite(thisPin, LOW);
  }
}

Andrew Zahn CODE 1.

int buttonpin = 2;
int potpin = 0;
int buttonvalue = 0;
int potvalue = 0;
int ledPin = 13;

void setup(){
  pinMode(buttonpin, INPUT);
  Serial.begin(9600);
  pinMode(ledPin, OUTPUT);
}



void loop(){
  potvalue = analogRead(potpin);
  buttonvalue = digitalRead(buttonpin);
  
  Serial.println(buttonvalue);
  Serial.println(potvalue);
  if (buttonvalue == HIGH){
    digitalWrite(ledPin, HIGH);
    delay(potvalue);
    digitalWrite(ledPin, LOW);
    delay(potvalue);
  }
  delay(100);
}