0% found this document useful (0 votes)
36 views3 pages

Arduino Pressure and Deck Shuffle Code

The document contains code for two problems related to Arduino programming. Problem 3-26 involves reading pressure values from the serial input, calculating the mean, largest, and smallest values, while Problem 3-30 involves shuffling a deck of cards and printing the shuffled values. Both problems utilize the Serial library for input and output operations.

Uploaded by

Cody Mauldin
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views3 pages

Arduino Pressure and Deck Shuffle Code

The document contains code for two problems related to Arduino programming. Problem 3-26 involves reading pressure values from the serial input, calculating the mean, largest, and smallest values, while Problem 3-30 involves shuffling a deck of cards and printing the shuffled values. Both problems utilize the Serial library for input and output operations.

Uploaded by

Cody Mauldin
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Homework 11

Problem 3-26

void setup() {

// put your setup code here, to run once:

[Link](9600);

double pres[100];

int count;

double input;

[Link]("Enter pressure value: ");

while([Link]() == 0);

input = [Link]();

[Link](input);

while(input >= 0 && count < 99)

pres[count] = input;

count++;

[Link]("Enter pressure value: ");

while([Link]() == 0)

input = [Link]();

[Link](input);

double mean, largest, smallest, sum;

largest = pres[0];

smallest = pres[0];

for(int i = 0; i <= count; i++)

sum = sum + pres[i];

if(largest < pres[i])


{

largest = pres[i];

if(smallest > pres[i])

smallest = pres[i];

mean = ((double)sum/(count+1));

[Link]("The mean is: ");

[Link](mean);

[Link]("The largest is: ");

[Link](largest);

[Link]("The smallest is: ");

[Link](smallest);

Problem 3-29
Problem 3-30

void setup() {

// put your setup code here, to run once:

[Link](9600);

int t, j, deck[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51};

for(int i = 0; i < 52; i++)

j = random(i,52);

auto t = deck[i];

deck[i] = deck[j];

deck[j] = t;

[Link](t);

You might also like