Tutorial 08: analogRead() and the Serial Port: Arduino Course for Absolute Beginners (ReM)

แชร์
ฝัง
  • เผยแพร่เมื่อ 9 ม.ค. 2025

ความคิดเห็น • 207

  • @programmingelectronics
    @programmingelectronics  4 ปีที่แล้ว

    ****If you like this, I think you'll like the premium Arduino training we offer. You can check it out here**** bit.ly/3lHyzcB

  • @ynnebbenny
    @ynnebbenny 9 ปีที่แล้ว +132

    I was really depressed before I found these tutorials. At the age of 50 and having never programmed before, I felt like Arduino was something I wanted to use, but would never be able to attain due to my coding illiteracy. In the past I have looked at coding tutorials and have tuned out very quickly. These tutorials have started at such a basic level, and assumed no prior knowledge. They are just what I need. Hey, even changing and uploading the flashing LED code gave me a hard-on :)
    I have a specific Arduino application in mind, and even after watching just 8 of your tutorials, I reckon I'll be able to make my project work using Arduino. Thanks so much for your marvellous teaching.

    • @programmingelectronics
      @programmingelectronics  9 ปีที่แล้ว +8

      +Ben Frawley Thanks for watching Ben - best of luck on your project.

    • @DevineIshaq107
      @DevineIshaq107 8 ปีที่แล้ว +7

      I am 62 and am in 7 nth semester of Bs.Cs programming Join some university bro |It is a very long traveling and full of joy

    • @CraigMansfield
      @CraigMansfield 5 ปีที่แล้ว +1

      Ben Frawley It's good news that all I need to get a hard-on is a flashing LED. My own I mean, not somebody else's hehe

    • @Richie_
      @Richie_ 3 ปีที่แล้ว

      Arduino keeps me occupied away from depression and anxiety. I've only just found Arduino.

  • @mojo8211
    @mojo8211 8 ปีที่แล้ว +1

    Fabulous course , I am 66 self taught Electronics hobiest . you opened a new world of controllers to me it will save me ages in circuitry , I love it keep this great work going, god bless you.

  • @ThomHall1
    @ThomHall1 11 ปีที่แล้ว +2

    Seriously - this is an AWESOME tutorial. Not too basic, or too fast. I just bought an Arduino board, but was overwhelmed trying to figure out how to do something useful. This has been perfect. Thanks for the huge amount of time you spent putting it together.

    • @matthewhall2318
      @matthewhall2318 11 ปีที่แล้ว +1

      Bam!

    • @programmingelectronics
      @programmingelectronics  11 ปีที่แล้ว

      So glad you like the course. Please let me know if there are other topics you would like covered.

  • @ehh.97
    @ehh.97 7 ปีที่แล้ว

    just bought an arduino after using picaxe for 8 years and went from building robots to barely being able to make an led blink. I was completely lost until I found these tutorials so thanks so much man!

  • @pugglez4798
    @pugglez4798 7 ปีที่แล้ว +1

    Thank you so much for zooming in on where you are when every people don’t I can never see it on my phone. Makes it clear to follow you too

  • @Richie_
    @Richie_ 3 ปีที่แล้ว +1

    I got my Arduino Rev 3 2 days ago and am finding your tutorials the best. ⭐

  • @mauroz100
    @mauroz100 9 ปีที่แล้ว +34

    Seriously, these tutorials are awesome.

  • @samflanagan77
    @samflanagan77 8 ปีที่แล้ว

    I took microelectronics in '92 at a community college. Haven't used it since(in employment capacity). Nonetheless, this was a perfect refresher course. "C" & Assembly language a big plus(I've had both).
    The end game is transitioning Arduino to a portal(such as PubHub) and then to a standard cloud computing service(such as IBM BlueMix). This will open up an endless range of applications that rely on a text messaging service to relay data to an person's smartphone.
    Thank you

  • @jasonvaughn3798
    @jasonvaughn3798 10 ปีที่แล้ว +3

    Your video's are are awesome! You provide the most in-depth explanation of how each portion of code works out of any tutorial or book I've read so far. Will recommend to others, thank you!

  • @snaprollinpitts
    @snaprollinpitts 10 ปีที่แล้ว +3

    thanks for being so explicit, it is the details that makes your videos so good!!!

    • @programmingelectronics
      @programmingelectronics  10 ปีที่แล้ว +1

      Thanks for the input! I will keep that in mind as I make more videos.

  • @drbasavarajans
    @drbasavarajans 2 ปีที่แล้ว +1

    Crystal clear, crisp & clean presentation. Thank you.

  • @videoart1496
    @videoart1496 8 ปีที่แล้ว +1

    these tutorials are so amazing for people who start now! excellent job! congratulations!

  • @MakzHD
    @MakzHD 10 ปีที่แล้ว +2

    Ordered my arduino, so just now i am learning to code, love theese videos has helped me a ton understanding the coding, Thanks you!

  • @labyrinth123456
    @labyrinth123456 8 ปีที่แล้ว +3

    Sir, u r a gem of a teacher
    May God bless u

  • @KingzOfSoccer
    @KingzOfSoccer 7 ปีที่แล้ว +4

    You are the best teacher i have ever seen

  • @nickklimiuk6345
    @nickklimiuk6345 6 ปีที่แล้ว +1

    These are the best tutorials I've found

  • @theflyingdutchman787
    @theflyingdutchman787 6 ปีที่แล้ว +1

    Amazing course! FYI: The ELEGOO UNO R3 functions and looks identical to the Arduino Uno. I purchased the "Elegoo Super Starter Kit" which comes with all the parts in this course (so far). I am not affiliated with the aforementioned brand.

  • @joedanero
    @joedanero 10 ปีที่แล้ว +1

    Added an LED and 330 resistor between ground and center pin for a dimmer with serial read out.
    Then I removed the pot and replaced with a force sensitive resistor to dim the LED.
    Fun times, but couldn't figure out how to get a friendly reading to the analog in for this.

  • @idiotluggage
    @idiotluggage 6 ปีที่แล้ว

    1023 is part of a binary counting system. It basically identifies 10 digits for binary 0000000000 = 0, 1111111111 = 1023 (1+2+4+8+16+32+64+128+256+512). This allows for 1024 optional inputs/outputs (0 is an option).

  • @robderop376
    @robderop376 6 ปีที่แล้ว +1

    wow dude this is lika 5 years ago uploaded but you are such a big help thanks alot

  • @falty
    @falty 6 ปีที่แล้ว +2

    Great teaching! very easy to understand and you had me laughing in several of your videos! I look forward to continue learning from you. Please keep them coming. Subscribed

  • @saurabhdamle4176
    @saurabhdamle4176 8 ปีที่แล้ว

    Thanks a lot for these tutorials. They are very very useful. And you teach a lot better than my school teacher.

  • @Spencer-vq7se
    @Spencer-vq7se 3 ปีที่แล้ว +1

    These tutorials beat everything else ive seen on youtube. Im feeling so much more confident now.

    • @programmingelectronics
      @programmingelectronics  3 ปีที่แล้ว

      Great - I am glad they are helping! Thanks so much for watching!

  • @Enderwiggan1
    @Enderwiggan1 7 ปีที่แล้ว +1

    You're a natural teacher

  • @TorIvanBoine
    @TorIvanBoine 7 ปีที่แล้ว +2

    in the updated sketch the output shows in voltage.
    the code "* (5.0 / 1023.0)" converts the 0-1023 number to volts.

    • @Fall3N_StaR
      @Fall3N_StaR 5 ปีที่แล้ว

      5.0/1024 and add to output +1 first, else nearly accurate result with minor % error

  • @SakshiShreya
    @SakshiShreya 9 ปีที่แล้ว +7

    Sir the tutorials are awsome.
    I had a question, why are we not using pinMode function in analogueRead?

    • @nashs.4206
      @nashs.4206 6 ปีที่แล้ว +8

      pinMode() lets you configure a pin as an input or output, but analogRead() already knows that the pin is configured as an input.

  • @allahbardero5481
    @allahbardero5481 9 ปีที่แล้ว +1

    These videos are great!!! Very easy and fun to follow!! Thanks for sharing!
    I have a question though:
    My 100K potentiometer warmed up a little, and I'm not shure if it produced malfunctioning in it. The serial monitor shows values between 0 and 160 aprox. Could I have done anything wrong?
    Thanks again!

  • @nabeelest
    @nabeelest 3 ปีที่แล้ว

    To get the value in voltage, make the following changes to code:
    float voltage=0;
    void setup() {
    Serial.begin(9600);
    }
    void loop() {
    float sensorValue = analogRead(A0);
    voltage=sensorValue*0.0048875855327468;
    Serial.println(voltage);
    delay(300);
    }

  • @Skandawin78
    @Skandawin78 7 ปีที่แล้ว +1

    Micheal ,you are a great teacher. your videos are awesome

  • @jingguopeng
    @jingguopeng 8 ปีที่แล้ว

    Thank you!These are the excellent tutorials for totally new user of Arduino

  • @honestlee4532
    @honestlee4532 5 ปีที่แล้ว

    While running this test, I wasn't getting any data updates in the Serial Monitor after unplugging and replugging in the USB cable, even though I had Autoscroll checked. To get around this, I closed the Serial Monitor window and opened it again and then I started to see the numbers again. So it seems like every time you unplug the USB cable you'll need to restart the Serial Monitor window. This happened in Windows 10 and Fedora 30. I have version 1.8.9 of the Arduino IDE installed on Windows and 1.8.5 on Linux.

  • @greggruger589
    @greggruger589 5 ปีที่แล้ว +1

    By far the best arduino videos!!! Plus no roblox music! I can’t thank you enough.

  • @chrismucyo4181
    @chrismucyo4181 10 ปีที่แล้ว +1

    Hey man i just wanted to say thnx and keep up the good work, these tutorials help a lot

  • @rmarier1
    @rmarier1 2 หลายเดือนก่อน +1

    In tutorial 8, I’m obviously missing something from previous lessons as l
    don’t understand why we don’t “initialize” this analogue potentiometer in the sketch. Could you elaborate on that please?
    I’m fairly green to Audrino and struggle with coding as well as most folks. These tutorials are amazing absolutely but l need to revisit them from time to time to refresh as that is just how my brain works 😊. I’m concentrating on understand the coding rather than committing them to memory.

    • @programmingelectronics
      @programmingelectronics  2 หลายเดือนก่อน

      Great question!!!
      OK, the "A0" does not need initialized because it is not a variable, it is just referring directly to a pin on the Arduino. When you select your board in the Arduino IDE, there is a "pin mapping" that takes place, and some pin numbers have shorthand names, for example A0 is actually the number 14, but you can type A0 instead. Kind of confusing...
      We could have made a variable to hold A0, like...
      int POT_PIN = A0; // but instead, we skipped the variable and just passed in A0 to the analogRead function directly.

  • @kallumarrowsmith2046
    @kallumarrowsmith2046 6 ปีที่แล้ว +1

    Thank you for these tutorials, they are brilliant

  • @aldrich1820
    @aldrich1820 6 ปีที่แล้ว

    Great videos, not sure if this has been asked, but why did you not declare the potentiometer as an integer before the void setup command?

  • @mickeymouse-lu2yk
    @mickeymouse-lu2yk 8 ปีที่แล้ว +1

    Awesome course - many thanks for walking through the material sooooo well. Silly question; is the only way to declare an analog input pin with a string as A0 is not an integer, seems wasteful hence the question
    Thanks again

    • @programmingelectronics
      @programmingelectronics  8 ปีที่แล้ว

      Great question. Actually, you can use the numbers 14 for A0, 15 for A1, 16 for A2 and so on. I am pretty sure the string "A0" is defined/read as 14 by the Arduino IDE - it is kind of a short hand for the number. I use the letters when addressing the pins, because it seems more readable to me, but either method works fine.
      And you could just make it a byte:
      byte SensorPin = A0;

  • @chirayuagrawal3317
    @chirayuagrawal3317 6 ปีที่แล้ว

    Can we create a seperate variable for A0(A zero) before the void setup() and then use the variable in analogRead parenthesis?

  • @renevillalta27
    @renevillalta27 7 ปีที่แล้ว +1

    io man thanks for share all this knowledge your explanations are really amazing, simple and great

  • @alexmedina2346
    @alexmedina2346 5 ปีที่แล้ว +2

    It's not reading a steady value. It jumps from 200's to 300's without me touching the potentiometer. Also I can't get it to go to 0 or 1023 it just stays jumping around those ranges. Maybe a little more If I try to stick the jumper wire deeper in to the 5V pin. lol. The digitalRead worked before though. I really felt that I understood this tutorial. I don't know if something is wrong with one of the components. Any suggestions? These are great tutorials!

    • @sarahfox5911
      @sarahfox5911 5 ปีที่แล้ว +2

      Hi! I was having this same problem. Is your wire connecting the middle lead of the potentiometer on the same side of the breadboard? This seemed to work with mine instead of having all of the wires connected on the same side :) Hope this helps.

    • @alexmedina2346
      @alexmedina2346 5 ปีที่แล้ว +1

      @@sarahfox5911 Hey! Yes that worked. Thank you Sarah. It makes sense now. The middle lead was on the other side of the potentiometer.

  • @CraigMansfield
    @CraigMansfield 5 ปีที่แล้ว +1

    Very very helpful to a N00B like me.
    Thank you!

  • @TarunShrivastava
    @TarunShrivastava 6 ปีที่แล้ว +1

    i like start from 1:30

  • @taranagnew436
    @taranagnew436 6 ปีที่แล้ว

    the buttons on the LCD shield are assigned to A0, so it would make sense to have the randomseed to A1, right and when I go to upload the code, it says error compiling
    #include
    LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
    #include
    #include
    int localKey = 1;
    int count = 0;
    long diceOne;
    long diceTwo;
    int countDelay = 220;
    int setColumn = 0;
    int SAMPLE_WAIT;
    int KEY_SELECT;
    void setup() {
    lcd.begin(2,16);
    lcd.setCursor(8, 0);
    lcd.print("Roll the dice!");
    }
    void buildUp() {
    lcd.clear();
    for (count = 0; count

  • @KVNRICH
    @KVNRICH 9 ปีที่แล้ว +8

    could not find a cup or a lemon but had a can of beer instead at hand

  • @karthickkeyan2286
    @karthickkeyan2286 6 ปีที่แล้ว

    sir please also explain how to connect and why so. the potentiometer and other appliances

  • @ActuallySettle
    @ActuallySettle 6 ปีที่แล้ว

    Absolutely outstanding tutorials.

  • @ahmedasaleh6547
    @ahmedasaleh6547 7 ปีที่แล้ว

    hi ... I have a question:
    why we did not add any resisters as the last tutorial?

  • @shashankrathor2235
    @shashankrathor2235 7 ปีที่แล้ว

    I want to ask that in tutorial 8 why there is no pinmode in void setup... how do we declare that either the pin is in output or input mode?

  • @bharath_rbp
    @bharath_rbp 5 ปีที่แล้ว

    sir why we are not giving pinmode of A0?
    or whether it always taked as input pinmode for A0?

  • @svakestor7219
    @svakestor7219 4 ปีที่แล้ว

    Thanks for the great tutorials. Are the pullup or pulldown resistors needed only for the digital pins? Don't the analog pins give false positives also?

  • @swgeek4310
    @swgeek4310 5 ปีที่แล้ว +1

    6 year old video's but SO helpful. Thanks

  • @David-rc8us
    @David-rc8us 9 ปีที่แล้ว +1

    Hi ! Again
    Day 4 with my Arduino Uno Tutorial 8 completed OK.
    Notes LED on board always on. Do not no why, maybe its how it was left from last sketch . (blink) Can it be turned of with a simple sketch . might try it myself.
    Notes TX LED running on and off fast.But if I change delay(1) to delay (1000) slows output down TX light blinks at the same rate as delay . They must be linked with delay .
    Is the TX LED showing when the Arduino is doing something ? ie sending data !
    Anyway thanks for a brilliant tutorial
    Regards
    David UK

    • @programmingelectronics
      @programmingelectronics  9 ปีที่แล้ว

      David dave Hi David - your suspicion is correct, the TX/RX light will illuminate when you Transmit/Receive bits over the Serial Port.
      When you load a new sketch, the previous one is erased from memory, there should be no "residual" effects.
      The issue with the on board LED at pin 13 being on all the times is relatively common and you can read about what other users have tried here:
      forum.arduino.cc/index.php?topic=96886.0
      As always, thanks for watching and your kind words. Best of luck!

  • @mbdelong
    @mbdelong 11 ปีที่แล้ว

    Why do you need to connect the other pin of the potentiometer to ground?

  • @SaadElectric700
    @SaadElectric700 7 ปีที่แล้ว

    Hello. How do I manage the led Variable resistance

  • @mohitpanwar7508
    @mohitpanwar7508 5 ปีที่แล้ว +1

    awesome tutorials
    sir you are the best...

  • @Audio_Simon
    @Audio_Simon 6 ปีที่แล้ว

    Two questions: Why don't we need to 'include' the serial library at the start of or code, but we do with other libraries? Why does serial.begin or serial.println need a dot, but digitalread or digitalwrite doesnt get formatted digital.read or digital.write?

    • @Audio_Simon
      @Audio_Simon 6 ปีที่แล้ว

      Also thanks for the clear better tutorials, I watched some others peoples but couldn't get on with them.

  • @prdlaserandleather6897
    @prdlaserandleather6897 4 ปีที่แล้ว

    i know this is a older video but i am just starting and my potentiometer has 5 pins and iv tried to use them all but the reading just floats from 300-400 and it dosnt change no matter what i do is there different code that need to be added for this one

  • @barotsantosh
    @barotsantosh 8 ปีที่แล้ว

    THANK YOU VERY MUCH SIR FOR YOUR SUPPORT .

  • @kyriacosvasiliou8342
    @kyriacosvasiliou8342 8 ปีที่แล้ว

    First off, I would just like to say thanks for the course. I am really learning alot from it. I have a question however. Why did you not use pinMode to set up A0 as an INPUT. I'm assuming it is not needed in this case for whatever reason. Can you please clarify? Many thanks.

  • @jeevankumarreddyravuru8710
    @jeevankumarreddyravuru8710 7 ปีที่แล้ว

    Hi i am doing a project on blinking led with delay, the thing is there is some code in the examples for a led blink delay changing using a potentio meter but for me I have 3 LEDs and 3 potentiometers, by using these 3 potentiometers i want to control the delay of 3 LEDs individually i.e led 'A' blinking delay will be controlled by potentiometer ' A' and similarly for LED B and C, i tried many times but result is not as expected ,i am new to the programming plz help me

  • @toygerx6735
    @toygerx6735 8 ปีที่แล้ว

    The video tutorials are amazing! Thank you so much. Quick question though. The program does not setup the A0 pin to be an input or an output. Obviously, it is an input in this case, but could there be a case were you might need to setup an analog pin as an output? or is the Arduino unable to provide analog voltage?

  • @jimmyleong9654
    @jimmyleong9654 8 ปีที่แล้ว

    Great tutorials! Quick question, noticed that pinMode isn't in void setup() as compared to the earlier tutorial on Digital sensors. Could you kindly clarify why?

    • @programmingelectronics
      @programmingelectronics  8 ปีที่แล้ว

      Great observation! That is because when using analogWrite() with a pin, the pinMode function is not necessary.

    • @jimmyleong9654
      @jimmyleong9654 8 ปีที่แล้ว

      Programming Electronics Academy Thanks for the kind reply and guidance! Is it safe to assume then that because Analogue mainly deals with sensors, sketch automatically takes it as pinMode(sensor,INPUT); .Whereby input will always be in numerical values (hence the type of sensor does not matter) as compared to digital where it could be an input/output with High or Low values only. Sorry if this sounds confusing.

  • @Chris122529
    @Chris122529 8 ปีที่แล้ว

    i love these tutorials, they helped so much

  • @amorgan93
    @amorgan93 5 ปีที่แล้ว +1

    Thank you so much for these tutorials.

  • @sangarp2001
    @sangarp2001 7 ปีที่แล้ว +1

    This vid solved my problem.Thank you.

  • @benbenameur8429
    @benbenameur8429 4 ปีที่แล้ว

    Hi
    but when i removing 5 v the ADC Continue read noise between 0 to 1023 . Is there a way to isolate this noise?

  • @cupbowlspoonforkknif
    @cupbowlspoonforkknif 10 ปีที่แล้ว +1

    Turning a knob and watching data change is so amusing :)

    • @programmingelectronics
      @programmingelectronics  10 ปีที่แล้ว +3

      David D I could do it all day...

    • @davidgeorge5109
      @davidgeorge5109 9 ปีที่แล้ว +1

      Open Source Hardware Group Excellent job! I'm a 15 yr old, who has no technical experience, and I'm following these tutorials perfectly. You are justifying my purchase of the Arduino Uno, thank you so much!

  • @meheershukla7861
    @meheershukla7861 9 ปีที่แล้ว

    hey i just wanted to ask that while up;oading stuff on the arduino board do we have to keep on overwriting a program on to another program

  • @sapperjohn256
    @sapperjohn256 9 ปีที่แล้ว +2

    great tutorials. i was wondering, why did you not declare A0 an input? thanks

    • @programmingelectronics
      @programmingelectronics  9 ปีที่แล้ว +5

      +SapperJohn Great question! By default, all pins are set as INPUTS, so you don't have to write it explicitly as an INPUT with the pinMode() function. Hope this answers your question. Have a good one!

    • @harshitrajput6865
      @harshitrajput6865 7 ปีที่แล้ว +1

      If i would have declared pin A0 as input using pinMode(), would the program still work in the same manner?

    • @angeld23
      @angeld23 7 ปีที่แล้ว +2

      Yes, it would.

  • @MrHaven-gg8js
    @MrHaven-gg8js 9 ปีที่แล้ว

    Hi! Can you help me changing my board? im using arduino 1.6.6 and i cannot find the IPST-SE board there so i cannot upload my program. Please help me. thx

  • @danielstankowski1307
    @danielstankowski1307 9 ปีที่แล้ว +1

    Love it!
    Please do more

  • @peoples_channel
    @peoples_channel 7 ปีที่แล้ว

    I want to make water detector. What all components do I need to have?

  • @LKbrilliant
    @LKbrilliant 8 ปีที่แล้ว

    Is there a way to get every value in 3 digit number like insted of getting 43, 6, 133 I need to get 043, 006, 133.
    I really like the way your presenting things. keep up the good work. Good luck

  • @lachiemcgregor5263
    @lachiemcgregor5263 10 ปีที่แล้ว

    hi there, first of all I would like to say thank you! for all these videos its really helped me out i have a bit of an issue though i am using a linear potentiometer and when i put 5 volts on one pin and the ground on the other it shorts it out and am wondering if i need to get a "analoge" potentiometer (sorry can't spell at all i suck at english anyways) thanks a lot keep up the good work. :)

  • @NeonblueIndustries
    @NeonblueIndustries 5 ปีที่แล้ว

    Will the integer value go higher than 1023 if the voltage went higher than 5v??????

  • @kguna74
    @kguna74 10 ปีที่แล้ว +1

    hi there, when I place ''int sensorValue = analogRead(A0)'' before/above void setup it doesn't work. Is it very important where we place the declaration? Is it how the program is read/scanned, like on a PLC ladder program, from top to bottom of the rung?? Great videos by the way, many thanks.

    • @programmingelectronics
      @programmingelectronics  10 ปีที่แล้ว +1

      Hi Pathy K, First off - great question! You can declare your sensorValue variable before setup(), but I would recommend initializing it when you are in the loop(). If you decide to initialize the variable before the loop, then it will only sample A0 pin once, and never update the value. If you use sensorValue = analogRead(A0), inside the loop, then every time the loop repeats, that value will get updated.
      That was a bit of a muddled response - hope it helps!

    • @kguna74
      @kguna74 10 ปีที่แล้ว +1

      I think I get it now. Many thanks.

  • @nguyenkhai1
    @nguyenkhai1 9 ปีที่แล้ว

    I'm just starting with the arduino. What arduino kit would you recommend?

  • @arofnogneu1134
    @arofnogneu1134 9 ปีที่แล้ว +1

    Would you fry your arduino if you swap the ground and 5V wire?

    • @programmingelectronics
      @programmingelectronics  9 ปีที่แล้ว +1

      arofnog neu No, it would be fine for this tutorial. You will notice a change in the output recorded at pin A0, the direction of the turn on your pot will produce the opposite result on the pin.

  • @rubendebien5557
    @rubendebien5557 9 ปีที่แล้ว +1

    void loop() {
    int sensorValue;
    // read the input on analog pin 0:
    int value = analogRead(A0);
    if(value = sensorValue){
    }
    else{
    Serial.println(value);
    }
    sensorValue=value;
    delay(1); // delay in between reads for stability
    }
    Do you think this code will work if I don't want to print all the values but only the ones that are different from the last one? I'm not experienced and this code might seem sloppy.

    • @programmingelectronics
      @programmingelectronics  9 ปีที่แล้ว +2

      +Ruben Debien You are definitely on the right track here! A couple things to look out for. When doing a comparison in the if condition, you want to use a double equal sign, like if(value == sensorValue) this will compare the values of 'value' and 'sensorValue'. If you just do the single equal sign, you end up assigning the value of 'sensorValue' to the 'value' variable.
      That being said, you might try using the "not equal" operator != to reduce the code a little..
      Something like this might work:
      int sensorValue;
      void setup() {
      // put your setup code here, to run once:
      }
      void loop() {
      // read the input on analog pin 0:
      int value = analogRead(A0);
      if(value != sensorValue){
      Serial.println(value);
      }
      sensorValue = value;
      delay(1); // delay in between reads for stability
      }

    • @berry2709
      @berry2709 7 ปีที่แล้ว

      Hello! , awesome tutorials. thank you! i am new to arduino and i want to build up on this tutorial. is it possible to get the serial monitor to only print out when i turn the potentiometer?
      -i want it to print out the value at the instant I turn the potentiometer and stop.
      -i do not want it to continuously print out all the values.
      i have tried this code above but it isnt giving me what i want.
      i'd be happy if you can help.
      thank you !

  • @nipunmittal6250
    @nipunmittal6250 6 ปีที่แล้ว +1

    can we also add a line
    int voltValue = (5/1023)*sensorValue;
    and then we can use
    Serial.println(voltValue);
    it may help us to get exact value

  • @believeinyourself999
    @believeinyourself999 6 ปีที่แล้ว

    Can u please give me the math to convert analougRead value to voltage🙇🙇🙇

  • @jaywenden1939
    @jaywenden1939 9 ปีที่แล้ว +1

    Is there a way to divide the 1023 by 5 and have it print like a number say 6.7 as a voltage into the serial monitor ?

    • @programmingelectronics
      @programmingelectronics  9 ปีที่แล้ว

      Jason Wenden If the variables that hold the value 1023 and 5 are both float data types, and the output variable is also a float, than i think it would work Ok.
      Here is more about the float data type:
      www.arduino.cc/en/Reference/Float
      Hope this helps some!

    • @jaywenden1939
      @jaywenden1939 9 ปีที่แล้ว +1

      I'll check it out now, thanks :-)

    • @Pr0m0t3d
      @Pr0m0t3d 9 ปีที่แล้ว +1

      Open Source Hardware Group I did that too, I divided 1023/5 and got 204.6, so all I did was add one line and change what it prints in a serial monitor.)
      Here's the line
      double sensorValueInVolts = sensorValue / 204.6;
      Serial.println(sensorValueInVolts);
      And that's all! : )

  • @dhairyanagodra6929
    @dhairyanagodra6929 8 ปีที่แล้ว

    dont we have to configure analog pin as a i/p or o/p..??

  • @pskbalaji000
    @pskbalaji000 11 ปีที่แล้ว

    sir how can we visualize the analog signal coming from the breadboard

  • @shayan3725
    @shayan3725 8 ปีที่แล้ว

    Great tutorial. But I do not understand why it says 'analogRead(AO);'. Why wasn't it 'analogRead(A5);', and what difference would it make?

    • @programmingelectronics
      @programmingelectronics  8 ปีที่แล้ว

      A0 refers to the analog pin that the potentiometer is attached to. Since there are 6 analog pins, you need to specify which one. You are basically telling the Arduino to measure the input at analog pin A0 - that is just the name pin. If you change where the center pin of the potentiometer is connected to pin A5 , then analogRead(A5) would be appropriate. Hope this helps some, best of luck!

  • @emirhansalisanchez1205
    @emirhansalisanchez1205 7 ปีที่แล้ว

    when i upload the code it shows different values in serial monitor i try to change the value but its keep o that way didn't change

  • @manishagrawal2211
    @manishagrawal2211 6 ปีที่แล้ว

    Sir, i want to map speed(km/hr) to degree of rotation of motor. How could I do that?

  • @friedmystery9123
    @friedmystery9123 8 ปีที่แล้ว

    I wanted to ask you if I can use any other item ( other than potentiometer ) because I'm not an adult and thus I don't have a lot of money to buy one.

  • @Sandrajanetq
    @Sandrajanetq 10 ปีที่แล้ว

    I love your videos! I have a question =). I connected an led to change the brightness as i turn the knob of the potentiometer. It works, however the led cycles from 0 brightness to completely bright as i turn the knob instead of being completely bright when the knob is turned to on side and completely off at the opposite side. It cycles 4 times as i turn it. Why is this so?

    • @programmingelectronics
      @programmingelectronics  10 ปีที่แล้ว +1

      When you read a value at the analog pin ( using analogRead() ), you will get values ranging from 0 (for 0 volts) all the way up to 1023 (for 5 volts), and everything in between. The analogWrite() function, however, tops out at 255.
      So my guess is that you are using the same variable you are recording with AnalogRead and sending it to analogWrite. Once analogWrite goes over 255, it will start back again at 0 (if I recall correctly), which would happen about 4 times in a full turn of your potentiometer.
      The way to solve this is to use the map() function.
      arduino.cc/en/Reference/Map
      Something like...
      /* Map an analog value to 8 bits (0 to 255) */
      void setup() {}
      void loop()
      {
      int val = analogRead(0);
      val = map(val, 0, 1023, 0, 255);
      analogWrite(9, val);
      }
      Hope this helps!

    • @Sandrajanetq
      @Sandrajanetq 10 ปีที่แล้ว

      Open Source Hardware Group Yes! that was the problem! I had realized what the problem was so i converted by creating a new float variable:
      float ledFade = sensorValue * (255.0/1023.0);
      and used ledFade in my analogWrite =).
      Your way seems much easier and new to me so I am going to try that. Thanks so much for replying =)!

  • @saisekhar7728
    @saisekhar7728 6 ปีที่แล้ว

    what happens if the potentiometre terminals are changed

  • @imonsarkar8749
    @imonsarkar8749 9 ปีที่แล้ว

    Sir,instead can we use,
    int analogButton = A0; ?
    Thanks again

    • @nreh0
      @nreh0 8 ปีที่แล้ว

      No, integer can only contain numbers, not letters. It would give an error.

  • @felipegarcia05189
    @felipegarcia05189 8 ปีที่แล้ว

    great video, i saw that you did not set a pinMode, is that because Analog pings A0-A5 are only INPUT?

    • @programmingelectronics
      @programmingelectronics  8 ปีที่แล้ว +1

      Great question! It is because all the I/O pin default to INPUT, so you don't have to explicity set them as INPUTS (however, I usually do - this lesson was an exception).

    • @felipegarcia05189
      @felipegarcia05189 8 ปีที่แล้ว +1

      +Programming Electronics Academy thanks for your reply, i appreciate it.

  • @dezinecoparvezilahi3713
    @dezinecoparvezilahi3713 9 ปีที่แล้ว +2

    plz tell me about wifi module that is es932

    • @programmingelectronics
      @programmingelectronics  9 ปีที่แล้ว

      +parvez ilahi I will add that as a request for the video cue, thanks for recommending!

    • @dezinecoparvezilahi3713
      @dezinecoparvezilahi3713 9 ปีที่แล้ว +1

      that module is esp32 and also can you tell me how to control blooth module with aediuno plz

  • @Himanshu-bu8hc
    @Himanshu-bu8hc 5 ปีที่แล้ว

    Insteaf of int if we use float what happens??

  • @acqurius-gx8lr
    @acqurius-gx8lr 5 ปีที่แล้ว

    how to read multiple analog pins without multiplexing.why all analog pins start reading voltage while only one is connected to DC source which is to measure how to resolve it without very using multiplex

  • @blbont0114
    @blbont0114 9 ปีที่แล้ว

    i think i;ve done everything as you've said but when the serial monitor is running the numbers only flick between 0 and 1, any suggestions?

    • @Terahspidgeon
      @Terahspidgeon 9 ปีที่แล้ว

      +BLB ONT01 It sounds like you plugged in the potentiometer to an digital pin or declared that A0 acts as a digital pin.
      Do you have to turn the knob to over half way before it jumps from 0 to 1? (you are using a potentiometer I take, not a switch?)
      Another option is that your potentiometer is busted and only allows to bring you from 0 to 0.01 volt or something.

  • @edsonrodriguez5347
    @edsonrodriguez5347 11 ปีที่แล้ว

    that was my homework! thanks Bro, really nice, i hope i can found more of my homework here xD

  • @mariosanchez1488
    @mariosanchez1488 10 ปีที่แล้ว

    First of all I would like to thank you for creating this awesome serie.
    With that said, I actually have a small question. At the beggining of the video you mentioned that your potentiometer had 1000k resistance. Is thats the case wouldnt it affect your voltage. So how did it reach the 1023?

    • @programmingelectronics
      @programmingelectronics  10 ปีที่แล้ว

      Mario Sanchez Great question! In a series circuit like this one, the entire amount of the voltage will be applied across the potentiometer. Since a potentiometer is like a voltage divider, when I have the potentiometer knob turned so that all the resistance is before the analog pin, then the analog pin will "see" the entire 5 volts. When we use the analogRead function, 5 volts translates to the number 1023, which is the value that gets returned. A bit of a difficult concept to fit in a small reply box, but I hope it helped some - Have a good one!

  • @tilemachostsiapras3224
    @tilemachostsiapras3224 8 ปีที่แล้ว

    really great videos , thank you , you helped a lot!!!