Using Arrays with Arduino

แชร์
ฝัง
  • เผยแพร่เมื่อ 21 ก.ย. 2024

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

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

    Great info. You are absolutely right to be concerned about inserting element values outside the size of your array. I learned first-hand you should always always always specify the size of your array when initializing. I spent several hours re-reading a multi-array code before I finally found the typo that bricked two Nanos by changing a value Beyond its array size. Fortunately I was able to salvage them by reloading their bootloader. However if I had specified the size of the array, the typo would have been caught when compiling and would have saved me hours of trouble.

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

    WELL DONE! Now I’m ready to use arrays.
    Thanks!

  • @mariaviklund4546
    @mariaviklund4546 4 หลายเดือนก่อน +1

    I was banging my head trying to get this to work on a project before i found this video. Now i know what i did wrong. Mixed the data types! Thanks so much!

  • @ChadKapper
    @ChadKapper 2 ปีที่แล้ว +3

    This a super-valuable lesson! Thank you!

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

    it is great thing to learn and ready "open my eyes " and how the person created the so interesting guiding in Arduino programming way ...keep up

  • @KW-ei3pi
    @KW-ei3pi 4 หลายเดือนก่อน +1

    Love your channel. It's probably the best source of videos for Arduino instruction.
    I've been watching your videos for about a year. I was wondering where you are from, as you have different way of pronouncing the word "put". It was very noticeable in this video. Thanks. Regards

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

      Thanks! I'm from the midwest, but I just say "put" wrong 😀
      I have no idea how I lived over 4 decades saying it incorrectly, but I am working on it! I don't even play golf.

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

    Very well explained! Thanks very much!

  • @tharchit9028
    @tharchit9028 8 หลายเดือนก่อน +1

    THANKS MY DEAR !

  • @jlr3636
    @jlr3636 ปีที่แล้ว

    Your explanation of what you are going is very clear, however an example of why or where to use an array escapes me. An example would help.
    Your videos on Arduino are among the best, thanks.

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

    Thanks for the video.
    Could you please do a video on the joystick library. Trying to convert an old analog joystick to digital using a pro micro. Could you show how to program the Hat, and triggers/switches so that the triggers and switches work like joystick switchers.
    Right now my switches work as keyboard commands trigger = A and so on.
    I have seen short programs that make the switches act as joystick commands, would like to see the longer version where each switch is its own bit of code.
    Hope this makes sense.

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

      Glad you liked the vid! Thanks for the recommendation on the joy stick library!

  • @peterlyne9378
    @peterlyne9378 ปีที่แล้ว

    Thank you so much, very well explained

  • @midianalbertokhaiyow8195
    @midianalbertokhaiyow8195 2 ปีที่แล้ว +4

    excellent video, I have a question, let's imagine I have many arrays, let's say those have names like red blue green, and each array has several elements that in some cases can be as few as 7 or 10, and in other cases they are as large as 300 elements, In the main function, what it does is take an array as for example the "green" one and execute anything with the elements, such as adding the elements to each other or subtracting them, that is not really the important thing, the important thing is that I want to learn is how to change the array that is being used in the function through serial communication, for example, command by serial communication "red" and in the main function it is executed but in this case instead of using the "green" array use the "red" and if I write "blue" then change the "red" for "blue" ...

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

      Great question! I’ll see if we can come up with a video to help on this.
      You might consider using a switch case statement to select the appropriate array based on the serial input.

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

      @@programmingelectronics Hello, thanks for your answer, I did not consider using a switch case, because there are too many arrays, neither consider using an array of arrays, because of the big difference between the content of arrays, since some contain few elements (4 or 10) and others contain many elements (300 or 400). I suppose that I could use pointer methods, what I am not clear about is how to convert a string sent by serial as "red" to a pointer, and then be able to use the pointer to fill it with the content of the "red" array and execute the code

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

      @@midianalbertokhaiyow8195 put the array names in a switch case that calls different functions depending on the color (array name). Then write a function to handle that array. If some of the functions do similar things, pass arguments to the function to determine how it process the passed array.

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

      @@midianalbertokhaiyow8195 I was thinking what @Bass Man mentioned below, but I may not fully understand what you're after. Sounds like a cool application though! We do have several lessons on using serial input on TH-cam that may be helpful on this potentially. Best of luck!

  • @jean-francoismaury5822
    @jean-francoismaury5822 6 หลายเดือนก่อน

    Really video, thanhs !

  • @voytechj
    @voytechj 2 ปีที่แล้ว

    @7:10 other elements will be initialized with default value, and for a type of byte it will be zero.

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

    Thank you! You explain it well. ;)

  • @joshuapitong899
    @joshuapitong899 2 ปีที่แล้ว

    Really helpful.🙌

  • @learn3715
    @learn3715 2 ปีที่แล้ว +3

    Great upload video! 👍 stay connected! 😍Like 👍👍👍

  • @senpuuxd1032
    @senpuuxd1032 ปีที่แล้ว

    How to remove something from array? I want remove uid tag from 2 dimensional array after he was scaned and compare to array i don't know how to so this and can't find simple (to me) way

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

    Is it possible to just pick up elements from 0 to 4 for example like in python? And why my array shows double the size of its elements? I didn't set the size of it

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

      Great questions!
      1) I believe you you are referring to "slicing" an array? Like you would with a list in python?
      myArray[] = { 10, 20, 30, 40, 50 }
      where... myArray[0:2] would give you the elements 10, 20
      ->To my knowledge you cannot slice arrays like this with Arduino.
      2) How are you finding the size of your array? Are you using the sizeof operator? If you use sizeof() it will return the number of total bytes in your array, not the total number of elements it can store. If you want to get the size of your array, you need to divide the sizeof(myArray) / sizeof(myArray[0] -> this will give you the actually size of the array.

  • @Dartheomus
    @Dartheomus 11 หลายเดือนก่อน

    It is killing me not to know where 155 came from. It's not an arbitrary value... it must have derived it from something. =P

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

    Why not start with a Hardware example? That would make it less abstract, because we end up building physical things, not just software programming...

    • @billferner6741
      @billferner6741 4 หลายเดือนก่อน +1

      Maybe this helps?
      I use it in a temperature measurement for calculating the average of 10 masurements.
      Each new data point is put in a different position of that array. Then computet the sum, decided by 10. Voila, the average temperature.

  • @billferner6741
    @billferner6741 4 หลายเดือนก่อน

    I miss an example of a two-dimensional array.

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

    Like! Zero, accept it and move on... It's the stupid machine that thinks it's a number, ie; 1001011. 0 has a value to it. Machines also think Green is a primary Color. Stupid machines.

  • @gaptoofgranny
    @gaptoofgranny 10 หลายเดือนก่อน

    I know you need to run ads in your videos in order to make a living, I get that, but you need to either place the ad before the lesson or after. Some of us need to keep the lesson going in one continuous stream, otherwise our methods of processing information in order to learn it gets disrupted and we have to start all over again. It really is bad practice. I couldn't do that when I was teaching, otherwise my students would look at me like I grew a second head and get absolutely thrown for a loop.