Question

In: Computer Science

Modify experiment 2 (below) such that the sensor value and data conversion to be shown on...

Modify experiment 2 (below) such that the sensor value and data conversion to be shown on both LCD display and Serial Monitor

Here is modification of above program that fade LED light based upon sensed voltage level. Connect LED on pin 9 with current limiting resistor in series. Execute modified version of following program.

const int led = 9;

void setup() {

// initialize serial communication at 9600 bits per second:

Serial.begin(9600);

}

// the loop routine runs over and over again forever:

void loop() {

// read the input on analog pin 0:

int sensorValue = analogRead(A0);

int dataConv = sensorValue*(256.0/1024);

//write analog equvivalant data on led pin

analogWrite(led, dataConv);

// print out the value you read:

Serial.println(sensorValue);

Serial.println(dataConv);

delay(1000);        // delay in between reads for stability

}

Thanks for your help!

Solutions

Expert Solution

// include the library code:
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(6,7,8,10,11,12);//lcd is connected to pin 6,7,8,10,11,12
const int led = 9;//led pin 9
int A0;//input pin
void setup()
{
pinMode(A0,INPUT);
pinMode(led,OUTPUT);
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
lcd.clear();
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}
void loop()
{
// read the input on analog pin 0:
int sensorValue = analogRead(A0);
int dataConv = sensorValue*(256.0/1024);
//write analog equvivalant data on led pin
analogWrite(led, dataConv);
// print out the value you read in Serial monitor:
Serial.println(sensorValue);
Serial.println(dataConv);
lcd.setCursor(0,0); // Sets the cursor to col 0 and row 0
lcd.print("SensorValue: "); // Prints SensorValue: to LCD
lcd.print((sensorValue)); // Prints value on sensorValue to LCD
lcd.setCursor(0,1); // Sets the cursor to col 1 and row 0
lcd.print("dataConv: "); // Prints dataConv: to LCD
lcd.print(dataConv); // Prints value on dataConv to LCD

delay(1000); // delay in between reads for stability
}

output compiled:


Related Solutions

The specification of a pressure sensor is shown below: Range of measurement: 10 psi to 250...
The specification of a pressure sensor is shown below: Range of measurement: 10 psi to 250 psi. Accuracy : ±0.2% of span. Transfer function : 0.5?/psi. Transfer function accuracy: ±0.1% Sensor output resistance, R : 2k? - 20k?. Sensor time constant: 200 ms . The resistance is then converted to a voltage with the transfer function: V= 10R/R+1000 1/Determine the uncertainty for measurement of 120psi. What is the possible pressure? 2/Determine the possible range of the transfer function. Interpret the...
Below is the data of a factorial experiment consisting of 2 levels of factor A, ie...
Below is the data of a factorial experiment consisting of 2 levels of factor A, ie levels 1 and 2, and 3 levels of factor B, ie levels 1, 2, and 3.                                                                                                 Factor B                                                                 Level 1                  Level 2                  Level 3                                 Level 1                  135                         90                           75 Factor A                                               165                         66                           93                                 Level 2                  125                         127                         120                                                                 95                           105                         136 Create an ANOVA table! And what can you conclude? α = 0.05 (Use manual...
Consider the reaction and data shown below Experiment Initial Rate [A] [B] 1 5.00 0.100 0.100...
Consider the reaction and data shown below Experiment Initial Rate [A] [B] 1 5.00 0.100 0.100 2 45.00 0.300 0.100 3 10.0 0.100 0.200 4 90.0 0.300 0.200 a. What is the rate law? b. What is the rate constant?
17) In an experiment the value for beta has been shown to be .7503, what is the power of this experiment?
  17) In an experiment the value for beta has been shown to be .7503, what is the power of this experiment?  18) A researcher did a one-tailed hypothesis test using an alpha level of .01, H0 was rejected. A colleague analyzed the same data but used a two-tailed test with α=.05, H0 was failed to reject. Can both analyses be correct? Explain your answer. 21) A psychologist would like to examine the effect of fatigue on mental alertness. An...
Experiment data taken in a batch reactor predicted the CSTR conversion should be 50%. However, the...
Experiment data taken in a batch reactor predicted the CSTR conversion should be 50%. However, the concentration measured in the actual CSTR was 57%. Suggest a reason for the discrepancy between the predicted and measured conversion.
Based on the data shown below, calculate the regression line (each value to two decimal places)...
Based on the data shown below, calculate the regression line (each value to two decimal places) y = x + x y 1 9.94 2 10.38 3 9.92 4 14.46 5 14.6 6 12.24 7 14.58
Based on the data shown below, calculate the regression line (each value to two decimal places)...
Based on the data shown below, calculate the regression line (each value to two decimal places) y = _____ x + _______ x y 4 33.1 5 32.2 6 29.4 7 26.7 8 25.2 9 24.8 10 22.2 11 19.4 12 17.8 13 16.4 14 13.1 15 11.3
Based on the data shown below, calculate the regression line (each value to two decimal places)...
Based on the data shown below, calculate the regression line (each value to two decimal places) y = _____ x + _______ x y 4 33.1 5 32.2 6 29.4 7 26.7 8 25.2 9 24.8 10 22.2 11 19.4 12 17.8 13 16.4 14 13.1 15 11.3
Based on the data shown below, calculate the regression line (each value to two decimal places)...
Based on the data shown below, calculate the regression line (each value to two decimal places) y =_____ x + ____ x y 4 33.1 5 32.2 6 29.4 7 26.7 8 25.2 9 24.8 10 22.2 11 19.4 12 17.8 13 16.4 14 13.1 15 11.3
Based on the data shown below, calculate the regression line (each value to two decimal places)...
Based on the data shown below, calculate the regression line (each value to two decimal places) y = x + x y 2 39.27 3 37.18 4 31.79 5 30.1 6 27.41 7 25.82 8 24.23 9 19.04 10 17.15 11 16.36 12 15.17 13 10.78 14 7.69 15 4.2
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT