Task 34:
int ranNum;
void setup()
{
Serial.begin(9600);
}
void loop()
{
for (int count = 1; count <101; count++)
{
ranNum = random(10);
Serial.println(ranNum);
delay(500);
}
delay(5000);
}
Task 35:
int ranNum;
void setup()
{
Serial.begin(9600);
}
void loop()
{
for (int count = 1; count <101; count++)
{
ranNum = random(10);
Serial.print(count);
Serial.print(".");
Serial.print(ranNum);
Serial.println();
delay(500);
}
delay(5000);
}
Task 36:
int ranNum;
int total;
int average;
void setup()
{
Serial.begin(9600);
}
void loop()
{
total = 0;
for (int count = 1; count <101; count++)
{
ranNum = random(10);
Serial.print(count);
Serial.print(".");
Serial.print(ranNum);
Serial.println();
total = (total + ranNum);
delay(500);
}
average = (total / 100);
Serial.print("The average of these random numbers is ");
Serial.print(average);
Serial.println();
delay(5000);
}
Task 37:
After playing around with the baud rate: I found that, when I set it to 300, i could see each character printed on the serial monitor seperately. When i set it to the maximum of 115200 it was incredibly fast, but i didnt even see any data flow errors.
Thursday, May 6, 2010
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment