How to start a second sketch in web IDE

I'm super new but finding few answers to searches about WEB IDE.
My immediate problem is I have copied some code from Matthew Heironimus which starts with */ but on compiling I get the message "expected unqualified-id before '/' token".
If I remove that line I get a message that says that the Joystick library doesn't exist but I have it in the WEB IDE Library (named 'Joystick').
I've done lots of searches but nothing includes one of my search terms - 'WEB IDE'.
I have uploaded other code to my Leonardo so it's onbviously my error.
Thanks for any help offered.

It is generally accepted that only ONE instance should ever be opened.
Testing some time ago worked Ok for the most part but could on occasion result in the loss of one of the sketches.
For multiple instances of the IDE it is often better to use the desktop versions.

Your topic was moved to its current location as it is more suitable.

Could you also take a few moments to Learn How To Use The Forum.

It will help you get the best out of the forum in the future.

Thank you

Hi @teebeej.

Please post a link to where you copied the code from.

I don't think it is a good search term.

The first thing to understand is that much of the information you will find about Arduino in general is also applicable to Arduino Cloud.

For example, the programming language is the same regardless of whether you are using Arduino IDE or Arduino Web Editor. So if you add "WEB IDE" to your searches you are filtering out the huge amount of information available about writing Arduino sketches that is not specific to Arduino Cloud. It would be better to simply use "arduino" as the search term in this case.

Second, even when you are searching for information specific to Arduino Cloud, "WEB IDE" is still a poor search term because nobody uses this term. The service as a whole, which includes Arduino Web Editor and Arduino IoT Cloud, is called "Arduino Cloud", but this "Arduino Cloud" brand is fairly new (it was branded "Arduino Create" before the recent name change).

"arduino" "web editor" are the best terms to use in searches for information about general sketch development specific to Arduino Cloud. "arduino iot cloud" should be used as the term in searches for information that is specific to Arduino IoT Cloud

Thank you, Ballscrewbob,
I will do as you suggest regarding the forum use. I tried to remove the previous sketch safely but every search I tried had no answers on the web editor. So once I can do that, i will do it one at a time !
Thank you for your help.

Thank you, ptillisch,
I got the code from MS Flight Sim forum - Roufinator - Setting up joystick (throttle quadrant) with pro micro/leonardo - Home Cockpit Builders - Microsoft Flight Simulator Forums
I will be using 'Arduino IDE' or 'Arduino Web Editor' as searches from now on.
Thank you for your help.

Hi @teebeej. I'm sorry for the slow response. I found time to look at the sketch and found it was written for an antique version of the "Joystick" library from before this change.

I was able to make the sketch compile by adding an additional line of code after line 148:

Joystick_ Joystick;

Please give that a try and let me know if you have any more compilation errors.

I only compiled the sketch and didn't test it on hardware, so it is possible that even after fixing the problem in the code that caused the compilation error, there could be some runtime problems caused by some unknown changes to the library over the last 6 years. If so, I can provide you with instructions for installing the old version of the library. But I think it is worth trying it with the modern version of the library first.

Hi ptillisch and thank for spending time trying to help me. I will try that over the weekend and let you know how I got on. In the meantime I've decided to download and use the desktop IDE, started the online course recommended and I'm up to part 6, so things are beginning to look a little clearer !
Thanks again,
Trevor.

OK, I'm glad you are trying the desktop IDE as well. The instructions I provided above are equally applicable whether you are using Arduino Web Editor or Arduino IDE so no adjustments are needed. But that is useful information in case it is necessary for me to provide library installation instructions because in that case the procedure is a little different in Arduino IDE than in Arduino Web Editor.

Hello again,
I started again on the desktop IDE and uploaded the Joystick library from Github. I know I'm thick and this is probably a goon question, but line 148 doesn't exist in my version of the code, it goes up to 113 in Notepad++. I also uploaded the whole post from the link I posted (to Flight Simulator 2020 )and it doesn't seem to belong there. I looked at the link in your post - 'this change' and the term seems to be after line 248 in the example, so I searched in the complete article (MSFS2020) for the preceding line for 'SendReport' and nothing turned up.
I'm sorry to burden you with this but I don't know what to try next.
Regards, Trevor.

I obtained the code from the link in the forum post you shared previously:

https://forums.flightsimulator.com/t/setting-up-joystick-throttle-quadrant-with-pro-micro-leonardo/395315

This modified Game Controller code can be found at:
https://codebender.cc/sketch:232199

This is line 148 of that sketch:

image

Are you copying the code from the text of Roufinator's forum post? I think that will be very difficult to work with because Roufinator did a major fail by posting the code without using the correct forum markup, which caused it to be severely corrupted by the forum software's renderer.

That is expected. They are two completely different programs. Please don't get confused by that link I shared. It is useful for someone who wants to understand why sketches written for an old version of the library don't compile when using the new version of the library, but all you really need to know is that you must now add this line to your sketches:

Joystick_ Joystick;

You can put off learning why that line is necessary until later in your Arduino journey.

Hi again ptillisch, Thanks ever so much for the clarification.
I am now using the code from codebender (that I had seen while travelling the ether) on the desktop IDE and added the 'Joystick_ Joystick;' line under line 148. Please confirm no #include or parentheses needed, just the semicolon. I have downloaded and confirmed the library is present and available.
As with yourself the code compiles but will not upload. I have tried several times, the board is connected according to the bottom line (Arduino Leonardo connected on com 5) but each time I try it stops almost immediately with the message 'Connecting to programmer: .
Found programmer: Id = "CATERIN"; type = S
Software Version = 1.0; No Hardware Version given.
Programmer supports auto addr increment.
Programmer supports buffered memory access with buffersize=128 bytes.
Programmer supports the following devices:
Device code: 0x44'
I read your post on this message but the fix seems to be to update to an older version (of the IDE). If I am correct which version do you think please?
Trevor.

I confirm.

Are you certain the upload failed? The output you shared is the output we would expect from a successful upload.

Did Arduino IDE indicate the upload failed? If the upload fails, you will see an "Upload error: ..." notification at the bottom right corner of the IDE window:

image

If the upload succeeds, you will see a "Done uploading." notification there:

image

Note that the success notification is hidden after a few seconds, so you might miss it if you aren't watching, but you can click the :bell: icon at the right side of the status bar to show the hidden notifications again.

If you didn't get an "Upload error: ..." notification then the upload was successful and you don't need to worry about this message. The red color of the text might give the impression that it indicates an error, but this is not so. The developers of the tool that produces this output made the decision to print even output that is not related to an error condition to the "standard error" (AKA "stderr") stream instead of the more common practice of printing it on the "standard output" (AKA "stdout") stream. Arduino IDE colors all output received from the stderr stream red.

It should not be necessary.

Hello again ptillisch and thanks again. Yes it has uploaded successfully and it didn't report an error message, just the 'Done uploading'. What threw me was how quick it was compared to the web editor, I should have realised that with no internet it woold be very much faster. Anyway it will be working because it now appears in USB game controller as just the 2 declared buttons according to the code.
I won't be able to test hardware connections further until I get home next week. I will do so and get back to hopefully announce success for others who may open the thread.
Back to lesson 7 !!!
Thanks again, T.

Excellent! I'm glad the compilation and upload is working.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.