Question

In: Computer Science

Using Arduino a) write a program that uses two potentiometers to adjust the values displayed on...

Using Arduino

a) write a program that uses two potentiometers to adjust the values displayed on the serial monitor. Have the two values displayed side by side via the serial monitor and each range from 0 to 255

Solutions

Expert Solution

Here is the completed code for this problem. Comments are included, go through it, learn how things work and let me know if you have any doubts or if you need anything to change. If you are satisfied with the solution, please rate the answer. If not, PLEASE let me know before you rate, I’ll help you fix whatever issues. Thanks

//using A0 pin for first analog input
const int analogInPin1 = A0;
//and A1 for second analog input
const int analogInPin2 = A1;
//variables to store values from potentiometers
int p1value = 0;
int p2value = 0;

void setup()
{
  Serial.begin(9600);
}

void loop()
{
  //reading sensor value from first potentiometer
  p1value=analogRead(analogInPin1);
  //wrapping signal to a value between 0 and 255
  p1value=map(p1value, 0, 1023, 0, 255);
  //doing the same for second potentiometer signal
  p2value=analogRead(analogInPin2);
  p2value=map(p2value, 0, 1023, 0, 255);
  //displaying both values in serial output
  Serial.print("Potentiometer 1: ");
  Serial.print(p1value);
  Serial.print(", Potentiometer 2: ");
  Serial.println(p2value);
}

/*SCREENSHOT OF CIRCUIT DIAGRAM, CODE AND SERIAL OUTPUT*/


Related Solutions

Write an Arduino Program that detects a reflective surface using the line sensor array of a...
Write an Arduino Program that detects a reflective surface using the line sensor array of a QTR-3RC (*Must be specific to this sensor! please this is important*) Must include a function that when called returns.. 0 (line to the left of the robot) 1 (line under the robot on the left side) 2 (line under the robot on the right side) 3 (line to the right of the robot) Output the results to the serial port in 0.5 second intervals...
Write an Arduino Program that detects a reflective surface using the line sensor array of a...
Write an Arduino Program that detects a reflective surface using the line sensor array of a QTR-3RC (*Must be specific to this sensor! please this is important*) Must include a function that when called returns.. 0 (line to the left of the robot) 1 (line under the robot on the left side) 2 (line under the robot on the right side) 3 (line to the right of the robot) Output the results to the serial port in 0.5 second intervals...
Write Arduino program to implement wiring three momentary switches to the Arduino board
Write Arduino program to implement wiring three momentary switches to the Arduino board
Multiple Choice/ Arduino Review -The Arduino uses what to assign analog values? a. Sine waves b....
Multiple Choice/ Arduino Review -The Arduino uses what to assign analog values? a. Sine waves b. PWM c. Square Waves d. Both b and c - Which Of the following is NOT an example Of a standard Arduino library? a. Servo b. TFT c. LiquidCrystal d. Thermo - The Arduino language is based on what? a. Python b. Java c. C/C++ d. HTML - How many channels of A/D conversion does the Arduino Uno have? a. 6 b. 13 c....
Write a program using c++. Write a program that uses a loop to keep asking the...
Write a program using c++. Write a program that uses a loop to keep asking the user for a sentence, and for each sentence tells the user if it is a palindrome or not. The program should keep looping until the user types in END. After that, the program should display a count of how many sentences were typed in and how many palindromes were found. It should then quit. Your program must have (and use) at least four VALUE...
Write the following in C language for Arduino: Write a program that turns on the LED...
Write the following in C language for Arduino: Write a program that turns on the LED at 25%, 50%, 75%, 100%, and then 0% brightness with a one second delay in between each change. Remember you are going to need to use a PWM pin and use the "analogWrite" command. The maximum value for our Arduino R3 boards is 255 and you need five steps (25%, 50%, 75%, 100%, and 0%) so you will need to determine the values for...
Write a program that uses an array of doubles initialized to whatever values you wish. Write...
Write a program that uses an array of doubles initialized to whatever values you wish. Write methods to calculate and return the minimum and a method to calculate and return the maximum value in the array. You must write YOUR ORIGINAL methods for minimum and maximum. You MAY NOT use Math class methods or other library methods. Write an additional method that accepts the array as a parameter and then creates and returns a new array with all the same...
In arduino: 1.Given two Arrays A= {2,4,7,8,3) and B={11,3,2,8,13). Write a program that find the numbers...
In arduino: 1.Given two Arrays A= {2,4,7,8,3) and B={11,3,2,8,13). Write a program that find the numbers into A but not in B. For the example C=A-B= {4,7} Print the values (Use for loops) 2.Create a vector of five integers each in the range from -10 to 100 (Prompt the user for the five integer x). Perform each of the following using loops: a) Find the maximum and minimum value b)Find the number of negatives numbers Print all results
Write the following in C language for Arduino: Write a program that increases the LED brightness...
Write the following in C language for Arduino: Write a program that increases the LED brightness in five steps with each press of the button. Remember you are going to using a digital input and the "digitalRead" command. You are going to need to use a PWM pin and use the "analogWrite" command. The maximum value for our Arduino R3 boards is 255 and you need five steps (25%, 50%, 75%, 100%, and 0%) so you will need to determine...
what is the following (ARDUINO): -Examples of a standard Arduino library -The Arduino uses a structured...
what is the following (ARDUINO): -Examples of a standard Arduino library -The Arduino uses a structured programming language-what type -Channels of A/D conversion on the Arduino Uno -The Arduino correlates temperature readings with what
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT