Task 46:
Here is the senders code:
const int dataSend = 13;
void setup()
{
pinMode(dataSend, OUTPUT);
}
void loop()
{
digitalWrite(dataSend, HIGH);
delay(8000);
digitalWrite(dataSend, LOW);
delay(2000);
}
Here is the receivers code:
Here is the senders code:
const int dataRec = 2;
int recData;
void setup()
{
Serial.begin(9600);
pinMode(dataRec, INPUT);
}
void loop()
{
recData = digitalRead(dataRec);
if (recData == HIGH)
{
Serial.print(recData);
}
else
{
Serial.println(recData);
}
delay(500);
}
Task 47:
The Roles were switched on each Arduino.
Task 48:
The sender's code:
const int dataSend = 13;
const int dataRec = 2;
int recData;
int dataState;
void setup()
{
Serial.begin(9600);
pinMode(dataSend, OUTPUT);
pinMode(dataRec, INPUT);
}
void loop()
{
dataState++ % 2;
digitalWrite(dataSend, dataState);
for (int count = 1; count <= 20; count++)
{
recData = digitalRead(dataRec);
if (recData == HIGH)
{
Serial.print(recData);
}
else
{
Serial.println(recData);
}
delay(50);
}
}
The receiver's code:
const int dataSend = 13;
const int dataRec = 2;
int recData;
int dataState;
void setup()
{
Serial.begin(9600);
pinMode(dataSend, OUTPUT);
pinMode(dataRec, INPUT);
}
void loop()
{
for (int count = 1; count <= 20; count++)
{
recData = digitalRead(dataRec);
if (recData == HIGH)
{
digitalWrite(dataSend, dataRec);
Serial.print(recData);
}
else
{
digitalWrite(dataSend, dataRec);
Serial.println(recData);
}
delay(50);
}
}
Task 49:
Sender's code:
const int dataSend = 13;
int state;
void setup()
{
pinMode(dataSend, OUTPUT);
for (int i = 1; i <= 200; i++)
{
state = i % 2;
digitalWrite(dataSend, state);
delay(1);
}
}
void loop()
{
}
Recievers code:
const int dataRec = 2;
int recData;
int pulseCount = 0;
void setup()
{
Serial.begin(9600);
pinMode(dataRec, INPUT);
}
void loop()
{
recData = digitalRead(dataRec);
if (recData == HIGH)
{
pulseCount++;
Serial.print(pulseCount);
delayMicroseconds(1500);
}
}
Task 50:
Did not have two Arduinos to test speeds.
Thursday, May 13, 2010
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment