analog read input arduino - analogRead - (Arduino Uno Programming for Beginners)

Поделиться
HTML-код
  • Опубликовано: 15 дек 2023
  • analog read input arduino - analogRead - (Arduino Uno Programming for Beginners)
    In this video I show how to use analogRead to analog read a potentiometer. I will explain how to convert the analog signal of a potentiometer into a digital signal and how to use the serial plotter to show a graph on the computer using Arduino IDE. I will also explain what analog reference means.

Комментарии • 10

  • @Volker-Dirr
    @Volker-Dirr 6 месяцев назад

    Very nice. That is exactly why i was watching all your videos, because i learned in the first 3 minutes new stuff. Thank you. (In fact the part about the floating point was a bit simplified, since you can also with a ".0". For example by "float voltage = (float) 5/2;".

    • @playduino
      @playduino  6 месяцев назад

      Thank you, this motivates me :).
      Yes, casting also works :)

    • @Volker-Dirr
      @Volker-Dirr 6 месяцев назад

      @@playduino You are definitly more skilled in elektronics than me. I only have got maybe a bit more c++ coding skills. In fact while coding I nearly never need floating points and i also use the adding ".0" trick only. Now i just wonder if casting the number internaly is done by a float or a double.
      I wonder a bit about that, since i experimented a bit on my Pi 5 and i was able to even measure ~2°C lower heat using "char" instead of "long". In old days i was always thinking only about space. But in fact you can also save power by that. So i wonder if a number like "2.0" is internaly used as a float or a double. Float will be more energy and space efficent, while double might be more exact, since even simple numbers like 1.1 are unlimited as binary number, so 1.1 as a double is more exact then 1.1 as float.
      Anyone knows the answer?

    • @playduino
      @playduino  6 месяцев назад +1

      @Volker-Dirr I am sure you have more c++ skills :) very interesting question! I only know that on Arduino Uno it makes no difference, because both float and double are exactly 4 bytes

    • @Volker-Dirr
      @Volker-Dirr 6 месяцев назад

      @@playduino ahh.. true. Even the R4 is 32-bit only. I just tried with the compiler explorer using x86-64 and the current clang and gcc version. They cast a number like 1.0 as a double.

    • @playduino
      @playduino  6 месяцев назад

      @Volker-Dirr interesting! I think 1.0 is always double and 1.0f is always float. Thx for sharing!

  • @KW-ei3pi
    @KW-ei3pi 4 месяца назад

    If I understand the video, using this method will give more accurate readings of analog voltage. Is that correct? This would be very valuable to me when reading a Joystick potentiometer. Please reply. Thank you.

    • @playduino
      @playduino  4 месяца назад

      it depends on how your schematic looks like. If you connect the joystick to VCC (5V supply) and to GND then you will actually get better analog readings if you stick to VCC (5V supply) as analog reference. This way, voltage drops will be compensated. Did you already try reading the Joystick or are you just planning on using one?