Thursday, April 29, 2010

Task 50 - How fast can you send a thousand 1/0 pulses and still count them accurately.

The most accuarate count we could get is half a second otherwise it would not display it accuarately.

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).

Task 48 - receiving and sending a copy back for checking.

I was working with BJ on this. On my arduino I had the following code:

int reciever = 2;
int LED = 13;

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

void loop(){
//val = digitalRead(reciever);
if (digitalRead(reciever)==1){
Serial.println("H");
digitalWrite(LED,HIGH);
}
else{
digitalWrite(LED,LOW);
Serial.println("L");
}
delay(500);
}

on BJ's arduino, he had the following code:

void setup() {
// initialize the digital pin as an output:
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
pinMode(2,INPUT);
}

// the loop() method runs over and over again,
// as long as the Arduino has power

void loop()
{
digitalWrite(ledPin, HIGH);
delay(1000);
if(digitalRead(2)==1){
Serial.println('H');
}
else{
Serial.println('L');
}
digitalWrite(ledPin, LOW);
delay(1000);
if(digitalRead(2)==1){
Serial.println('H');
}
else{
Serial.println('L');
}
}

When blink goes on BJ's arduino it sends a signal to my arduino that outputs high or low to the screen, depending if it is a one or two. It then sends it back to BJ's arduino and does the same thing and outputs high or low to the screen.

Monday, April 26, 2010

47- reverse roles

For this, we just swapped the roles of what the arduinos were doing. BJ had blink going, while I had his previous code on my Arduino. Then the same principles were applied as task 46.

Task 46 - Sending a signal from one Arduino to another

I paired up with BJ to get one signal from one arduino to the other. BJ had the following code on his arduino:

BJ Smid*/

int reciever = 2;
int LED = 13;

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

void loop(){
//val = digitalRead(reciever);
if (digitalRead(reciever)==1){
Serial.println("H");
digitalWrite(LED,HIGH);
}
else{
digitalWrite(LED,LOW);
Serial.println("L");
}
delay(500);
}


I just had blink programmed on my arduino. This allowed my arduino to pass over a signal to BJ's arduino telling it whether or not my LED was blinking. If it was lit up, the arduino would send a signal telling BJ's arduino to light up an LED, otherwise it would send a signal to make sure it was off. BJ's arduino would also output to the screen whether it was high(lit up) or low(off).

Task 45 - infrared transmitter sends pulses to the receiver.

I have had a bit a trouble getting this to work outside of class, however I have been able to get this working in class using the blink exampler. I have the transmitter pluged into pin 13 and ground and that sends pulses to the reciever, which is in series with an led. These were also grounded and have 3v3 to power them. This then makes the led to blink on and off.