Question

Perform the following program and present flowchart    Using Arduino create a program that averages two arrays...

Perform the following program and present flowchart   


Using Arduino create a program that averages two arrays of N elements where N is a whole number. A temperature control process has two temperature sensors A and B. From each sensor N samples are taken and stored in a different array. You need to average the values ​​of the two sensors in another array and print it on the screen. The voltage range of the sensors ranges from 0 to 5 Volts (0 ⁰C to 100 ⁰C).

Example;

For N = 10

Array samples sensor A: {{1.4} {1.2} {1.3} {1.2} {1.3} {1.1} {1.4} {1.2} {1.1} {1.4}}

Array samples sensor B: {{1.4} {1.2} {1.1} {1.4} {1.5} {1.7} {1.8} {1.0} {1.1} {1.4}}

Array average: {{1.4} {1.2} {1.2} {1.3} {1.4} {1.4} {1.6} {1.1} {1.1} { 1.4}}

0 0
Add a comment Improve this question Transcribed image text
Answer #1

The program the above question is given below :

#include <OneWire.h>
#include <DallasTemperature.h>
// Data wire is plugged into pin 2 on the Arduino
#define ONE_WIRE_BUS 2
// Setup a oneWire instance to communicate with any OneWire devices
// (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);
// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);
const int numReadings = 10;
int readings[numReadings]; // the readings from the analog input
int readIndex = 0; // the index of the current reading
int total = 0; // the running total
int average = 0; // the average
void setup() {
// start serial port
Serial.begin(9600);
Serial.println("Temperatuur sensor by MAI©: 1min");
// Start up the library
sensors.begin();
for (int thisReading = 0; thisReading < numReadings; thisReading++) {
readings[thisReading] = 0;
}
}
void loop() {
// subtract the last reading:
total = total - readings[readIndex];
// read from the sensor:
readings[readIndex] = digitalRead(2);
// add the reading to the total:
total = total + readings[readIndex];
// advance to the next position in the array:
readIndex = readIndex + 1;
// if we're at the end of the array...
if (readIndex >= numReadings) {
// ...wrap around to the beginning:
readIndex = 0;
}
// calculate the average:
average = total / numReadings;
// send it to the computer as ASCII digits
Serial.println(average);
delay(1000); // delay in between reads for stability
}

Add a comment
Know the answer?
Add Answer to:
Perform the following program and present flowchart    Using Arduino create a program that averages two arrays...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • A program that averages two arrays of N elements where N is a whole number. A...

    A program that averages two arrays of N elements where N is a whole number. A process of temperature control has two temperature sensors A and B. From each sensor N samples are taken and They store in a different arrangement. It is necessary to average the values ​​of the two sensors in another arrangement and print it on the screen. The voltage range of the sensors ranges from 0 to 5 volts (0 0C to 100 0C) Make with...

  • Using Arduino create a program that performs the temperature control of an oven. The thermocouple sensor...

    Using Arduino create a program that performs the temperature control of an oven. The thermocouple sensor it works 0 oC at 100 oC delivering a voltage of 0V through a transducer to 5V. It is necessary to average the voltage of 10 sensor samples to have better accuracy in the measurement. If the average temperature is higher than 50 degrees then the cold water recirculation pump is turned on for 30 seconds. Simulate the sensor with a voltage divider using...

  • Design a program using a RAPTOR flowchart that has two parallel arrays: a String array named...

    Design a program using a RAPTOR flowchart that has two parallel arrays: a String array named people that is initialized with the names of twenty of your friends, and a String array named phoneNumbers that is initialized with your friends’ phone numbers. The program should allow the user to enter a person’s name. It should then search for that person in the people array. If the person is found, it should get that person’s phone number from the phoneNumbers array...

  • PLEASE HELP ME WITH THIS TASK 3.1 (FLOWCHART) AND TASK 3.2 (SOURCE PROGRAM). THANK YOU! Given...

    PLEASE HELP ME WITH THIS TASK 3.1 (FLOWCHART) AND TASK 3.2 (SOURCE PROGRAM). THANK YOU! Given below is a partially completed C program, which you will use as a start to complete the given tasks. #define SIZE 9 #include <stdio.h> int compareAndCount (int[], int[]); double averageDifference (int[], int[]); void main() { } int compareAndCount(int arr1[SIZE], int arr2[SIZE]) { int count = 0; for (int i = 0; i < SIZE; i++) { if (arri[i] > arr2[i]) count++; } return count;...

  • PLEASE HELP ME WITH THIS TASK 3.1 (FLOWCHART) AND TASK 3.2 (SOURCE PROGRAM). THANK YOU! Hint:...

    PLEASE HELP ME WITH THIS TASK 3.1 (FLOWCHART) AND TASK 3.2 (SOURCE PROGRAM). THANK YOU! Hint: the number array in task 2 is work for task 3 in figure 1.   Given below is a partially completed C program, which you will use as a start to complete the given tasks. #define SIZE 9 #include <stdio.h> int compareAndCount (int[], int[]); double averageDifference (int[], int[]); void main() { } int compareAndCount(int arr1[SIZE], int arr2[SIZE]) { int count = 0; for (int i...

  • Using the following create the nessecary static methods to pass random arrays with the TempartureWithArrays and...

    Using the following create the nessecary static methods to pass random arrays with the TempartureWithArrays and Temperature classes -------------------------------------------------------------------------------------- public class TemperatureWithArrays {    public static final int ARRAY_SIZE = 5;    public static void main(String[] args)    {        int x;        Temperature temp1 = new Temperature(120.0, 'C');        Temperature temp2 = new Temperature(100, 'C');        Temperature temp3 = new Temperature(50.0, 'C');        Temperature temp4 = new Temperature(232.0, 'K');        Temperature tempAve =...

  •      program will enter data into two single dimension arrays (do not st...

         program will enter data into two single dimension arrays (do not store duplicate values in arrays)      program will find the union and intersection of the two arrays using one function      program will find the symmetric difference of two arrays      program will display the union, intersection, and symmetric difference   */     short* input_data(short size);   // function to dynamically allocate and array and enter data into the array void display_data(short *data, short size); // function to display data in an array void get_union_intersection(short...

  • c++ help Write a program that: Creates two finite arrays of size 10 These arrays will...

    c++ help Write a program that: Creates two finite arrays of size 10 These arrays will serve as a storing mechanism for student grades in Classes A and B Uses a loop to populate the arrays with randomly generated numbers from 0 to 100.These numbers will represent student grades. Compute average grade of each class. Finally, output the two arrays and the message with two averages and best class. ("Class A average is: 65.43; class B average is: 68.90. Class...

  • This C++ Programs should be written in Visual studio 2017 PROGRAM 1: Comparing Using Arrays to...

    This C++ Programs should be written in Visual studio 2017 PROGRAM 1: Comparing Using Arrays to Using Individual Variables One of the main advantages of using arrays instead of individual variables to store values is that the program code becomes much smaller. Write two versions of a program, one using arrays to hold the input values, and one using individual variables to hold the input values. The programs should ask the user to enter 10 integer values, and then it...

  • Coding in C++ Write a program using structures to store the following weather information: - Month...

    Coding in C++ Write a program using structures to store the following weather information: - Month name - Day of month (Monday, Tuesday, etc) - High Temperature - Low Temperature - Rainfall for the day Use an the input.txt file to load the data into weather structures. Once the data for all the days is entered, the program should calculate and display the: - Total rainfall for the data - Average daily temperatures. (note: you'll need to calculate the days...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT