Thursday, April 29, 2010

Task 49 - series of pulses, a 100, about 1ms long, to the other.

I also did this task with BJ. On my arduino the code i used was:

int reciever = 2;
int LED = 13;
int count = 0;

void setup(){
pinMode(reciever,INPUT);
Serial.begin(9600);
}

void loop(){
if (digitalRead(reciever)==1){
count++;
Serial.println(count);

}
else{
}
delay(500);
}

BJ's code was:

void loop()
{
while (count < 1000){
digitalWrite(ledPin, HIGH);
delay(500);
digitalWrite(ledPin, LOW);
delay(500);
if(digitalRead(2)==1){
Serial.println('H');
}
count++;
}

}

This counts the incoming signal on my arduino when it is equal to 1 (high).

No comments:

Post a Comment