Notifications
Clear all

Merge Two Arduino IDE Sketches - Crazy_Blink - Part 1

31 Posts
5 Users
12 Reactions
531 Views
(@davee)
Member
Joined: 3 years ago
Posts: 1765
Topic starter  

Hi Bill @billinfl,

  First, well done for struggling through my 'box set' sized post!

  I have been playing with software for around half a century, and still make silly mistakes that I can't spot for hours or more ... favourites are things like '1' (i.e a one) when it should be 'l' (the letter) ... easy to spot on their own, but more difficult when embedded in a word, like a variable name. So I can sympathise, but other than to say, if you get to this stage, take a break (with coffee or alternate beverage), and come back later, I don't really have a concrete answer.

If it is a 'logical' mistake ... e.g. a programme 'runs', but doesn't do what you want, then if you have a sympathetic ear you can describe it to, even if they do not understand the details, then sometimes just describing it to them, may trigger a thought as to why it might not be playing nicely.

You could even try just describing it to yourself, especially if you can't persuade anyone else to listen... imagine you need to describe the workings of your programme in a meeting, perhaps to a small class of students who will be polite, but not afraid to ask questions. Figure out what you will say ... you might feel a little silly doing it, but it can work! You may suddenly realise there is a contradiction between your hopes and reality.

-------------

I confess I don't presently know why your code is being awkward, but if you have tried the above 'suggestions', then please feel free to post it on the forum.

I suggest you post a request, 'pretending' this is a new request for help. As with any such request, I would like to see:

  • A brief synopsis of what you would like the programme to achieve
  • A brief synopsis of what it does instead
  • A code listing that anyone looking at the post can 'simply' download and paste onto their own machine. 

The first two items need only be a sentence each.

For the code, I am guessing there will be about three source files, which might be in more than one directory. I suggest you 'zip' them all up into a single zip file, and attach it to the request, so that any reader can simply download the zip file, and extract them in a 'ready to compile' form.

(Of course, only send the source files ... e.g. .ino, .cpp, .h, not the files the compiler produces, which might be in the same directory)

Obviously, feel free to add any other information you think might be helpful. This is just a minimal list.

--------

Everyone finds programming difficult at first, and it is continually getting more challenging, so don't worry that you are the only one struggling.

Best wishes, and I look forward to your reply, Dave


   
Lee G reacted
ReplyQuote
(@billinfl)
Member
Joined: 5 months ago
Posts: 40
 

@davee

Hi Dave. Just wanted to give you an update since it's been a while. I am happy to report that the widget counter project is proceeding nicely, now that the two sketches have been merged(!) I now just need to do the physical mounting of the widget containers in their final locations, and also get started on the physical design and layout of the electrical components, which, up to now, have been slip shodded together with four or more breadboards! I'm hoping that the final "box" takes up a lot less space, and winds up looking more like a finished "product", and less like a spaghetti wire nightmare. I will be shopping for a soldering station so as to increase my chances of success with getting everything to work once it's gone from bread to PC board. (This is the fun part for me)! I will endeavor to make the final box as small as possible, since I don't have much room for it where it needs to live.

I (again) want to say thanks to you and others on this board for all of your help and guidance, as well as your sketch suggestions and modifications, which (no surprise to me) the sketches you provided to me worked first time both before and after merging, not to mention your suggestion of the IC's needed for the large LED to be driven. The calibration info was also really helpful, since I don't think the whole thing would have worked without it. 

Now, about the merging:

As much as I would like to be reporting that I completed your tutorial, and then extrapolated that information on to the job of merging the two sketches,(LED counting, and widget weighing),  and I successfully got things to work, that did not happen. As you could probably tell from my post from May 25th, I had spent a long time trying to troubleshoot the issues I was having with some weird behavior with the Crazy Blink merges, that I was looking for help and getting pretty frustrated. That was true, so much so, that I felt like I would probably never get it straightened out and any "fun" that I had hoped to have on my way to success with the tutorial had pretty much dried up. I then started looking at the merging of "my" two sketches, thinking that I had learned enough from your tutorial to tackle that merge, but after spending way too long and trying so many combinations that I'm now pretty sure that I hold the modern day record for error messages after hitting upload.(I must (again) say that my inability to get through the tutorial is not due to any shortcoming it has, but rather MY failure to properly follow along and not screw up ANY of the fine details, which I'm really good at.

Then, an interesting thing happened.A few days later,  I was looking at some billiards videos on you tube, when I saw some "suggested" videos about Arduino, (which I get a lot now), and one of them said "You can use chat GPT for your Arduino sketches and more"! I had heard of Open AI, and not really paid much attention, but this got my attention. So, LONG story just a little longer, I signed up with GPT, and right away asked it if it could merge these two sketches. It needed about 8 seconds to think, and then spat out a few pages of code and then it said:  "Please copy and paste this code into a blank sketch and your program should now function fine for you, let me know if you need anything else......." As you can probably guess, it worked perfectly.

I'm not sure how you and others on this board feel about this technology, but it sure helped me out when I was about to "bag" the whole project. Sure, it would have been great to have figured it out on my own, but since I just don't seem to have what it takes, I'm ok with looking at it as if I'm not good at math, why would I be doing long division and multiplying complex fractions with paper and pencil and maybe an abacus, when I can just grab the calculator? Guilty as charged!!

Thanks again to all involved, especially Dave. I look forward to learning more from the folks here as this and other future projects come up. I still have a ways to go with this project before I can call it "done".

Bill 

 

 

 

 

 


   
Lee G reacted
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 4 years ago
Posts: 7334
 

@billinfl AI is ok for small simple problems like this, but just ask it to create an accounts receivable or payable or HR or even something as mundane as inventory control. Since two of those have multiple answers and only one answer is correct for a given enterprise I think the AI will need a lot of human help.

I have to admit I am a bit impressed if it created your sketch that easy. It would be instructive to the community if you published the result. I did it in a couple minutes, but I have over 50 years experience and have real not artificial intelligence.

Also publish the question you asked the AI so we can try it on other AIs to see if there is any difference.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 4 years ago
Posts: 7334
 

@billinfl I recently went through the new soldering station exercise. What I found recommended most often was the Hakko FX951-66 or the next model down the FX-950. I also got a bunch of tips especially the different sizes of wedge shaped for PCB work.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
ReplyQuote
(@billinfl)
Member
Joined: 5 months ago
Posts: 40
 

@zander Hi Ron. Interesting about the limited smarts of the AI. I guess it will need more learning time to get to your level! Thanks for the info about the stations. They both are the real deal for sure. Do you think it's worth it to spend the extra for the digital vs. analog(950) temp setting? Which do you use? Also, could you suggest a flux/solder, or tip(s) choice for the work I'm about to undertake? Thanks!

Also, I will attempt to post the code that the AI gave me, as well as the comments it made, that I didn't even ask for.  What was most shocking (to me), was how fast the whole thing went. I would estimate that after I signed up with the service, the entire interaction took less than 2 minutes. I gave it the sketches I had, I asked the question, the sketches were merged in about 8 seconds, I pasted what it gave me  into a blank sketch, I uploaded it (the whole time thinking.....this CAN'T work, right?), and boom, the system worked first time. I was so impressed,(and relieved) that I just sat there throwing stuff in and then taking it out for like 20 minutes!

Anyway, here's what I can post:

Screenshot 2024 06 03 at 5.21.04 PM
Screenshot 2024 06 03 at 5.27.15 PM
Screenshot 2024 06 03 at 5.26.48 PM

 


   
ReplyQuote
(@billinfl)
Member
Joined: 5 months ago
Posts: 40
 

Looks kind of small, and blurry. Sorry!


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 4 years ago
Posts: 7334
 

@billinfl As far as the code, put the two sketches you fed it and the output into a zip file, no need to get fancy, we can deal with that.

I got the digital. Just easier to see for me and there are probably a few tricks it can do that I have yet to use.

I have regular paste, special tinning paste, but mostly use liquid rosin flux. Lot's of different size desoldering braid, flux in a syringe, and mixed flux and solder balls in a syringe. Do your research, lots of these products are fake as in terrible performance. If in doubt check with Rossman Repair Group, he is a solder god.

For solder I have two spools, one is 0.8mm for heavy work it is 60/40 Tin/Lead, the other is for fine work and it is 0.38mm Sn63 Pb37 No clean water washable.

My everyday tip is a medium wedge. It is a T15 D16 (see pic) the tip needs cleaning. Here is an Amazon link, but do NOT pay that price, get a set that includes this plus a smaller and bigger if possible and shop around. I just did a quick search on Amazon and found one for about $10. LINK

Let me know if you have any further questions about soldering, tools, and supplies. My tendency is to see what the pros use and then see if I can afford it. If not, check LOTS of reviews, many are paid for so maybe natch up the pro picks with more budget oriented items by the same manufacturer.

Here is a picture of the D16 tip. It is about 2mm wide at the tip. Here is an amzon link to a practice board. Link

IMG 8484

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 4 years ago
Posts: 7334
 

@billinfl Here are links to two useful tools. You might not need the cradle if you have the other, but I got both just in case. There are cheaper versions, mine ended up in the bin. Here is the Link

This is the best 3rd hand I have ever seen. I think Bill has it also. Link

At 82 I am not so steady any more so I really appreciate these tools.

In case you have not noticed, like Bill I am in Canada so you may have to adjust the Amazon links by changing .ca to .com.

 

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
ReplyQuote
(@davee)
Member
Joined: 3 years ago
Posts: 1765
Topic starter  

Hi @billinfl,

  Thanks for the update.

I am pleased that you managed to solve your problems, and sorry you had a hard time, before AI stepped in. Perhaps I should have explained that the tutorial was not a quick fix solution, but rather an attempt to explain some of the issues and approaches to consider. Unfortunately, doing this over a forum is tricky, as you were bound to hit a problem, and whilst this can be fixed in a moment when both parties are in the same place, it can easily become impossible when they are limited to a messaging discussion. I had hoped to have a little more interaction, but completely understand how difficult that is, to achieve. However, I hope you learnt some useful hints from the time you spent. In reality, we can all struggle at times, and it can be very frustrating.  However, if you persevere, you will find it gets easier.

As for use of AI, although I have very little direct experience, I can see it is developing very quickly, and will be become as ubiquitous as many other computing and electronic devices. Furthermore, I am sure many people will make a comfortable salary by being capable of utilising the tools effectively, and I wish them well. And of course, that does not exclude amateurs and others, benefitting in their own individual ways, as well.

However, as with most things in life, I am cautious that the commercial, and possibly political, pressures will result in the technology being deliberately misused, over sold and 'over-trusted'. When the machine produces a 'correct' result, then it is obviously very convenient, and may be better than could have reasonably produced by humans. However, we have all seen examples where the same machines have produced obvious drivel. However, the 'obvious drivel' is easy to discard ... the tricky part is who, or what, will be capable of spotting the 'non-obvious drivel'? The latter, may appear highly plausible, but have disastrous consequences.

So whilst, I encourage you to investigate it further, I also recommend you try to understand what it is telling you, and use it as a 'personal tutor', so that you can review its recommendations in a meaningful way, and not just assume it's a convenient sage, providing answers on demand, and hope they are always correct. Used in the right way, I think it may become a very powerful tool.

------

As Ron (@zander) has already mentioned, I think you have some valuable experience to share, and whilst I appreciate you have posted some photos, they are not very convenient. In particular, I like to look at code on my own machine, where I can 'poke around', which would mean retyping, etc. So, if you could please help us all by spending a little time supplying the information in a more convenient form, that would be appreciated.

I think at least a few of us on the forum would like 'machine' readable versions, of all the steps, including original source files, the instructions to chatGPT, and the resulting replies, which hopefully, can be directly uploaded as files. Admittedly, the forum sometimes objects to certain file types, but the easy fix is to 'zip' them up, possibly all into the same zip file, prior to uploading, so that we can 'imagine' the sequence you experienced.

Of course, I would not wish you to spend a lot of time on this, so please use your discretion and ingenuity to deal with any parts that are tricky to supply. The intention is to convey the information, not fulfil some bureaucratic requirement.

------------

Well done for getting this far with your project, and I wish you well in your next phase of turning it into a small and robust product.

Best wishes, Dave


   
Lee G reacted
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 4 years ago
Posts: 7334
 

@billinfl Since all you need to do is copy the two original sketches somewhere convenient like your desktop, copy the AI created sketch to the same place, now select all 3 files and right click and select compress. (I am on a Mac so I am guessing about the actual names but the same concept will exist)

Now reply to this post or another of the posts in this topic, click Attach Files at the bottom and navigate to your desktop to finish the process.

 

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
ReplyQuote
(@billinfl)
Member
Joined: 5 months ago
Posts: 40
 

@davee Hi Dave. Thanks for your support as always.As far as providing you with more information about my interaction with Chat GPT, there really isn't anything I left out. There were no instructions, no preamble, no searching around the website. I logged on to the OpenAI site, which is pretty bare, except for the box where you  type in your question, which I did:

 "Can you merge these 2 Arduino sketches into one?" I attached the 2 sketches (the ones you gave me) to my question, and , seconds later, I was using the Widget Counter and (almost) crying happy tears.

Ron has asked me to please post the actual code that the machine sent to me to better evaluate it, along with the 2 sketches you directed me to use (from your original feasibility study) all into one zip file, which (watch it, cause I can hear you laughing) I've done for the first time ever today. (Hope it worked!) For that, please see my response to Ron.

Thanks again. Bill 

 


   
ReplyQuote
(@billinfl)
Member
Joined: 5 months ago
Posts: 40
 

@zander Hi Ron. Thanks much for all the tool info. Looks like I've got some tool research (and Shopping!) to do.

I will have more questions for you as time goes on. Thanks in advance!

Also, your description on how to post the zip with all 3 sketches was easy to follow. Even for me. Here it is.

Bill

 


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 4 years ago
Posts: 7334
 

@billinfl Do you see now how simple that was?

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
ReplyQuote
(@billinfl)
Member
Joined: 5 months ago
Posts: 40
 

@zander Now THAT was an easy one. I need more of those!


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 4 years ago
Posts: 7334
 

@billinfl The important thing is to recognize where you were going wrong, that is how we learn.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
Lee G reacted
ReplyQuote
Page 2 / 3