if you want to remove an article from website contact us from top.

    what is the output of the program given below if a voltage of 5v is supplied to the pin corresponding to the a0 pin on an arduino uno?

    Mohammed

    Guys, does anyone know the answer?

    get what is the output of the program given below if a voltage of 5v is supplied to the pin corresponding to the a0 pin on an arduino uno? from screen.

    What is the output of the program given below if a voltage of 5V is supplied to the pin corresponding to the A0 pin on an Arduino UNO? [code] vo

    What is the output of the program given below if a voltage of 5V is supplied to the pin corresponding to the A0 pin on an Arduino UNO? void setup() {...

    Forums Technology Question

    What is the output of the program given below if a voltage of 5V is supplied to the pin corresponding to the A0 pin on an Arduino UNO? [code] vo

    Thread starter Như Quỳnh Start date Sep 17, 2021 N

    Như Quỳnh

    New member

    Sep 17, 2021 #1

    What is the output of the program given below if a voltage of 5V is supplied to the pin corresponding to the A0 pin on an Arduino UNO?

    Code: void setup() { Serial.begin(9600); pinMode(A0, INPUT); } void loop() {

    int s = analogRead(A0);

    Serial.println(s); } A. null B. Error C. 0 D. 1024

    Sort by date Sort by votes

    Đ

    Đàm Ngọc Lan

    New member

    Sep 17, 2021 #2 Answer: D

    Explanation: The Arduino UNO’s analog pins map the value of the sensed voltage to an internal numbering scale which makes it easier for the programmer to work since it is more difficult to analog voltage levels in programming practice. Thus, for a value of 5V, which reaches the maximum limit, we get a value of 1024.

    Upvote 0 Downvote

    You must log in or register to reply here.

    What is the use of the tan() function?

    Previous Thread

    What is the value of “val” in the following program if the pin 12 is given 5V 3 times? [code]...

    Next Thread Share: Facebook Twitter Reddit Pinterest Tumblr WhatsApp Email Link

    Tìm kiếm

    Forums Technology Question

    स्रोत : 123hoidap.com

    Read Analog Voltage

    Open-source electronic prototyping platform enabling users to create interactive electronic objects.

    Read Analog Voltage

    Tutorials > Examples > Basics > ReadAnalogVoltage

    This example shows you how to read an analog input on analog pin 0, convert the values from analogRead() into voltage, and print it out to the serial monitor of the Arduino Software (IDE).

    Hardware Required

    Arduino Board

    10k ohm potentiometer

    Circuit

    Connect the three wires from the potentiometer to your board. The first goes to ground from one of the outer pins of the potentiometer. The second goes to 5 volts from the other outer pin of the potentiometer. The third goes from the middle pin of the potentiometer to analog input 0.

    By turning the shaft of the potentiometer, you change the amount of resistance on either side of the wiper which is connected to the center pin of the potentiometer. This changes the voltage at the center pin. When the resistance between the center and the side connected to 5 volts is close to zero (and the resistance on the other side is close to 10 kilohms), the voltage at the center pin nears 5 volts. When the resistances are reversed, the voltage at the center pin nears 0 volts, or ground. This voltage is the analog voltage that you're reading as an input.

    The microcontroller of the board has a circuit inside called an analog-to-digital converter or ADC that reads this changing voltage and converts it to a number between 0 and 1023. When the shaft is turned all the way in one direction, there are 0 volts going to the pin, and the input value is 0. When the shaft is turned all the way in the opposite direction, there are 5 volts going to the pin and the input value is 1023. In between, analogRead() returns a number between 0 and 1023 that is proportional to the amount of voltage being applied to the pin.

    Schematic

    Code

    In the program below, the very first thing that you do will in the setup function is to begin serial communications, at 9600 bits of data per second, between your board and your computer with the line:

    Serial.begin(9600);

    Next, in the main loop of your code, you need to establish a variable to store the resistance value (which will be between 0 and 1023, perfect for an intdatatype) coming in from your potentiometer:

    int sensorValue = analogRead(A0);

    To change the values from 0-1023 to a range that corresponds to the voltage the pin is reading, you'll need to create another variable, a float, and do a little math. To scale the numbers between 0.0 and 5.0, divide 5.0 by 1023.0 and multiply that by sensorValue :

    float voltage= sensorValue * (5.0 / 1023.0);

    Finally, you need to print this information to your serial window as. You can do this with the command Serial.println() in your last line of code:

    Serial.println(voltage)

    Now, when you open your Serial Monitor in the Arduino IDE (by clicking on the icon on the right side of the top green bar or pressing Ctrl+Shift+M), you should see a steady stream of numbers ranging from 0.0 - 5.0. As you turn the pot, the values will change, corresponding to the voltage coming into pin A0.

    See Also:

    setup() loop() analogRead() int Serial float

    BareMinimum: The bare minimum of code needed to start an Arduino sketch.

    Blink: Turn an LED on and off.

    DigitalReadSerial: Read a switch, print the state out to the Arduino Serial Monitor.

    AnalogReadSerial: Read a potentiometer, print its state out to the Arduino Serial Monitor.

    Fade: Demonstrates the use of analog output to fade an LED.

    ReadAnalogVoltage : Reads an analog input and prints the voltage to the serial monitor

    Last revision 2015/07/29 by SM

    Last revision February 05, 2018, at 08:43 PM

    स्रोत : www.arduino.cc

    Arduino Programming Questions and Answers

    This set of Arduino Multiple Choice Questions & Answers (MCQs) focuses on “Finding Out Program Outputs”. 1. What is the output of the program given below if a voltage of 5V is supplied to the pin corresponding to the A0 pin on an Arduino UNO? void setup() { Serial.begin(9600); pinMode(A0, INPUT); } void loop() { ... Read more

    Arduino Questions and Answers – Finding Out Program Outputs

    « Prev Next »

    This set of Arduino Multiple Choice Questions & Answers (MCQs) focuses on “Finding Out Program Outputs”.

    1. What is the output of the program given below if a voltage of 5V is supplied to the pin corresponding to the A0 pin on an Arduino UNO?

    void setup() { Serial.begin(9600); pinMode(A0, INPUT); } void loop() {

    int s = analogRead(A0);

    Serial.println(s); } a) null b) Error c) 0 d) 1024 View Answer

    Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!

    advertisement

    2. What is the value of “val” in the following program if the pin 12 is given 5V 3 times?

    int val=0; void setup() { Serial.begin(9600); PinMode(13,INPUT); } void loop() {

    int s = digitalRead(13);

    if(s==1){ val=val+1; } } a) null b) 113 c) 3 d) 2 View Answer

    Check this: Electrical & Electronics Engineering Books | Electrical Engineering Books

    3. What will the output for the code given below be, if executed on an Arduino UNO?

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

    Serial.print(sizeof(int));

    } a) 3 b) 1 c) 2 d) 8 View Answer advertisement

    4. What is the output of the following program?

    void setup() {

    String my_str = "This is the sentence";

    Serial.begin(9600);

    my_str.replace("sentence", "Arduino sketch");

    Serial.println(my_str);

    } void loop() { }

    a) “This is the sentence”

    b) “This is the ARDUINO SKETCH”

    c) “This is the Arduino Sketch”

    d) null View Answer

    5. What will be the nature of the output of the program?

    long rn; void setup() { Serial.begin(9600);

    randomSeed(analogRead(0));

    } void loop() {

    randNumber = random(300);

    Serial.println(rn); delay(1000); }

    a) Series of purely mathematical indeterministic random numbers

    b) Series of purely mathematical deterministic random numbers

    c) null

    d) Series of indeterministic random numbers based on noise

    View Answer

    6. What is the output of the following line of code?

    void main() {

    printf("%lu\n", sizeof(char));

    } a) 21 b) %fdf c) 1 d) null View Answer

    7. What will be the output of the following code given below?

    void main() { int a = 0; double d = 10.21;

    printf("%lu", sizeof(a + d));

    } void loop() {} a) 23 b) null c) 8 d) 10.21 View Answer

    8. What does the following code do?

    void main() {

    int* ptr = (int*)malloc(100 * sizeof(int));

    }

    a) Static Memory Allocation

    b) Static Memory Clearance

    c) Dynamic Memory Allocation

    d) Dynamic Memory Clearance

    View Answer

    9. What is the output of the code given below?

    void main() { Serial.begin(); int x = 2;

    printf("%d\n", sizeof(x++));

    printf("x = %d", x);

    } a) 2 b) 4 c) Runtime Error d) null View Answer

    10. What will be the output of the following code given below?

    void main() { int a = 10; double d = 10.21;

    printf("%lu", sizeof(a + d));

    } a) 8 b) null c) 9 d) 20.21 View Answer

    Sanfoundry Global Education & Learning Series – Arduino.

    To practice all areas of Arduino, here is complete set of 1000+ Multiple Choice Questions and Answers.

    « Prev - Arduino Questions and Answers – The sizeof() Function

    » Next - Arduino Questions and Answers – IR Sensor

    Related Posts:

    Practice Electrical & Electronics Engineering MCQs

    Apply for Arduino Internship

    Apply for Electrical Engineering Internship

    Buy Electrical Engineering Books

    Buy Arduino Books advertisement

    Recommended Articles:

    Arduino Questions and Answers – Setting Pin Mode

    Arduino Questions and Answers – Analog Input Output

    Arduino Questions and Answers – The setup() Function

    Arduino Questions and Answers – The loop() Function

    Arduino Questions and Answers – IR Sensor

    Arduino Questions and Answers – Time Functions

    Arduino Questions and Answers – Board Pinout Structure

    Arduino Questions and Answers – Digital Input Output

    Arduino Questions and Answers – Operators

    Arduino Questions and Answers – Datatypes

    advertisement

    Additional Resources:

    Arduino MCQ Questions

    Analog Circuits MCQ Questions

    C++ Algorithm Library

    IoT MCQ Questions

    Microcontroller MCQ Questions

    Popular Pages:

    Electrical and Electronics Engineering MCQ with Answers

    Event Handling in Java with Examples

    Electrical Engineering MCQ Questions

    Electronics and Communication Engineering Questions and Answers

    Delegates in C#

    स्रोत : www.sanfoundry.com

    Do you want to see answer or more ?
    Mohammed 8 day ago
    4

    Guys, does anyone know the answer?

    Click For Answer