Hi, I have been posting in another section of Arduino for part of a project I am working on, but now after success I am ready to move on to developing the software to control the Arduino .
What I have been trying to figure out is what do I need to know to be able to create a simple form like I have in Visual Studio 2010 in order to click buttons, or create a slider that uses the values of 0-255 or 0-1042 ish and communicate the changes (in speed) to the board.
In a nutshell I have setup the Arduino to send a PWM signal at 89Hz. It is controlling a treadmill. Now what I would like to be able to do is vary the duty cycle from a PC based program on a desktop. I am going to have to do some calculations later to represent actual Miles Per Hour, but for now I would like a slider or click buttons for speed. I am more than likely at this point just going to use the buttons in 10% intervals and I will probably cap out around 70%.
Any suggestions? I am trying to stick with C++ I am not proficient with it by anymeans, but i am trying to learn it while doing this project.
The Playground (under Learning on the home page) has a section, Interfacing with Software, that shows how to use a variety of languages on the PC to talk to the serial port that the Arduino listens to.
C++ is one possible language, but building Windows Forms applications is a pain in the ass using C++. The serial port is a bitch to use, too.
C#, on the other hand makes designing forms, and attaching callbacks, a matter of drag and drop and click. The serial port class is a piece of cake to use, too.
The structure of C# is not the same as that of C++, but programming is more a matter of logical thinking and application of available functions/methods/statements than it is use of a particular language.
I've "seen" the interfacing with software section but since I am just learning how to program, I wanted some more advice on what to use. What I will end up doing with this is creating a sub-program that can be controlled by a main program that controls speed based on events from the user or other programming.
Can 1 program running C++ control a second running C# relatively easy?
The reason I am fixated with the idea of C++ is that I want to be able to program in a very common language that can be used on multiple platforms (Arduino, Windows, Mac and Linux) and a language that uses the least amount of processing power because it will end up being graphics heavy.
I really dont know what a callback is, I've come to the conclusion based on basic searches that I am going to end up needing them, but Wikipedia explanations of callback functions just confused me more. My dummies book does even describe them that well -
Last night I was messing with the programming and trying to learn how each function worked in Arduino.
What I ended up doing was putting a variable (dutyCycle) as Serial.read... it worked ok. but Obviously the Ansii problem occured.
What is the best workaround for that? I found a few basic math tutorials, but I dont want to add the numbers that are coming in, I want the buffer to see the entry as a whole entry, or at least make it so that as they are coming in it is building an entire string instead of adding them together.
Basically, the Ansii is not capable of an interger 1042, so would I need to create a library with premade values? Which is what I was going to go ahead and do next. But how would I use the library with Serial.read? If Serial.read = X - refer to library value X and report Value C attached to X? (I know thats not legitimate programming language but its the basic command that I need).
In my opinion C/C++ is not ideal for cross platform apps. You will need to compile a different version for each platform.
Programs written for the Java Virtual Machine (JVM) are generally portable between systems as long as the JVM is already installed. Code for the JVM can be written directly in Java (which is at least as tedious as C) or in other languages such as JRuby (which I use) that sit on the JVM.
Another option might be Python. I'm not quite sure how portable a piece of Python code would be, especially if it has a GUI interface.
Do you think Java is an acceptable platform for heavy graphics? Every time I have run a Java app or program, I feel like it and its graphics are slow. I am familiar with Java being a better cross platform application, but my experience with its presentation has always been disappointing.
Python is doable for me, I might look into it too, but how well does the Arduino communicate without too many recodes? I am going to get out my books later this evening and look at the basic language and capabilities (got to replace a stator on the motorcycle here in a bit).
Rickmc3280:
unfortunately it is game quality graphics.
Sorry, I can't help there. I never had the slightest interest in computer games. I was usually bored so quickly I couldn't even find the energy to learn how they worked. My kids liked them - probably still do.
The normal PWM with analogWrite() takes a value from 0 - 255 and your symptoms seem very like the problem one gets when an integer is forced into a byte.
Is your Serial.println(integerValue) giving the correct value? Why are you not printing dutyCycle which is the actual thing which is used? Why is dutyCycle defined differently from integerValue?