In the book I am studying, Maik Schmidt's Arduino - A Quick Start Guide, some of the projects use the Processing IDE to display results, such as the project building an ultrasonic distance measuring device with temperature compensation.
Once I had the code typed in for both Arduino and Processing, and ran the project, I was not getting any data display on processing's interface. So I downloaded the code from the publisher's site and it ran OK. I figured I must have a typo somewhere. Eventually I verified my Arduino half would run OK with the downloaded Processing half. I then set out to compare my typed code to that downloaded line by line to find the error. After overlooking it several times I finally discovered my mistake. I had accidentally capitalized a function name in its void declaration:
void SerialEvent(Serial port) {
needed to be
void serialEvent(Serial port) {
Now, from what I have learned in Arduino, that would never have passed the "Verify" step before uploading the code to the UNO. It would have indicated an error and hopefully highlighted that line to help me find it. But there doesn't seem to be a "Verify" selection in the Processing 1.2.1 IDE menus. And when I clicked on Run in Processing, it did not generate any errors at the bottom of the IDE window like Arduino IDE would do. It just displayed the constructed data display screen, but it was not in motion with the data it should have been getting. My only clue was that the temperature and distance data was supposed to be streaming at the bottom of the Processing IDE window. It did on the downloaded code, but it did not on my typed in code. So I focused on the part of the sketch that would be sending that text to be displayed, and eventually found the above error.
So I am wondering if there is a way to do the same thing as the "Verify" step for Arduino when using Processing? I searched the forum here but did not find anything close to a pertinent answer.
In the Arduino IDE, the verify step runs the compiler and linker, but does not upload the code to the Arduino. The upload step runs the compiler and linker and uploads the results to the Arduino.
In the Processing IDE, the Run step runs the compiler and linker, and executes the program. There is not a separate step to just run the compiler and linker.
Now, from what I have learned in Arduino, that would never have passed the "Verify" step before uploading the code to the UNO.
This is, unfortunately, not a valid assumption.
The serialEvent function in the Processing application IS implemented. It just doesn't do anything, unless you provide a different implementation. So, it is not an error to not provide an implementation, if you don't care when serial data arrives. Providing a function with a different name is not an error, either, since there is the possibility that you will call your similarly named function later.
The author(s) of the book you were reading should have made it clear that you are overwriting a system function, and that it is important to make sure to spell the name exactly like the function you are overloading.
But, it is an easy thing to overlook, so don't be too hard on them for not mentioning that fact, and learn to be careful with function names in the future.
The author does mention the need to be careful about syntax and case, but in this incident it was just a mistake on my part. Because I know how crucial syntax is, I like to keep a close eye on the display as I enter each line of code. Looking back and forth from the book to the PC often causes me to lose my place in blocks of code which repeat or appear similar in the book, so I often get snagged that way too and end up typing the wrong code into my current location if I am not careful. It all boils down to having a lot to watch all at one time. Once I get deeply enough into this to automatically recognize these kinds of slip-ups I hope to more easily avoid them. I will try to review the rules for what needs to be upper case and lower case in the code. That should help. I also like to go back through the code of each completed project and comment pretty much ever line describing what it does. That causes me to make sure I understood the code for every line (which is what launched my initial confusion as to where to find references for much of the undescribed code being encountered).
But for now each page is presenting new and different information, so for the most part I am trying to type the code without yet understanding how it all works. After I get it into the IDE and verify it, I then read the passages that follow the code and explain what the author is doing as he wrote the code. So during the typing, missing a case change on a single word is pretty easy to do. But your explanation does make sense. Although most of these kinds of typos have yielded an error saying that some expected prerequisite was missing, or not declared, I guess there could be instances where a function name might simply be accepted even if wrong, as long as nothing else later tried to use the misnamed function.