Hello, is there any way to write code not using the Arduino app? I would like to make a GUI in Java/C#/HTML and then write code like that and upload it to the uno. I would just need 3 different commands like "digitalWrite(led1, HIGH);" digitalWrite(led1, LOW);" and "delay(x)" (the x i could input). Thanks.
You can communicate with the sketch running on the Arduino over the serial port - any language has libraries to interact with a serial port (the specifics will vary depending on your language, I don't do java or C#). You would have the sketch read the serial port waiting for commands, and then react appropriately, while the program running on the computer would send commands and listen for responses from the Arduino, if appropriate. There are many examples of how to handle serial commands from the Arduino side.
Well Im interested in making a user interface with buttons and inputs for delays and such... So I dont really think I can communicate with serial port then
Croxyz:
Well Im interested in making a user interface with buttons and inputs for delays and such... So I dont really think I can communicate with serial port then
Why on earth not?
Maybe I'm not clear on what you're trying to do.
Okay maybe im not making things clear. I need to make a program that writes code before the arduino even gets connected to the pc.
Croxyz:
Okay maybe im not making things clear. I need to make a program that writes code before the arduino even gets connected to the pc.
The IDE? You don't need an Arduino to be connected to be able to write (and compile for that matter) code with the IDE.
But I guess that's not what you want. It sounds like you want the Arduino board to be able to execute the commands that you mention (e.g. when they are typed in in a terminal program). For that you need to write an interpreter (Arduino sketch) that you compile and load in the Arduino. And next you can write the PC side of things.
Croxyz:
I need to make a program that writes code before the arduino even gets connected to the pc.
and from the Original Post
is there any way to write code not using the Arduino app
Do you mean that you want to generate code that can be uploaded to the Arduino without using the Arduino IDE or the C/C++ programming language?
If so you would need to write your own compiler. That would be possible, but it would be a very challenging long term project.
You can write C/C++ code for the Arduino without using the editor in the Arduino IDE.
Please clarify exactly what you want to achieve.
...R
I wan't to make miniBloq but far simpeler. With only 4 outputs that were predetermined(port 5=led1,
port 6=led2 ,port 7 = led3, port 8=led4).There would be 4 buttons. And you could press a button that said led1 and there you could input 5 seconds. So that would write into a txt file or somewhere else:
digitalWrite(led1, HIGH);
delay(5000);
digitalWrite(led1, LOW);
And when you finish with making your code like that you can compile and upload it to an arduino.
And when you finish with making your code like that you can compile and upload it to an arduino.
This is not an Arduino question. This is a C#/Java/whatever question. And yes, that can be done.
I suggest that you start by generating the bare minimum sketch (setup() and loop()). With the pre-defined pins, you can add them in the beginning and set them up in setup(). When a 'block' is added, you insert the relevant code in the loop part.
Croxyz:
So that would write into a txt file or somewhere else:digitalWrite(led1, HIGH);
delay(5000);
digitalWrite(led1, LOW);And when you finish with making your code like that you can compile and upload it to an arduino.
The easiest way to do that is write a PC program that takes your txt file and uses the command-line Arduino to compile and upload the code.
You will, of course, need to make a valid .ino file with setup() and loop() functions. It would not be too difficult to get a PC program to wrap that sort of thing around the sort of code you have above. You will, however, need code to define the variables such as led1, and set the pinMode() for I/O pins etc. All of that could require some complex programming. So it may be easier for the user to write a valid Arduino program in the first place.
I use the Geany editor for writing all my code and I have written this Python program to call the Arduino IDE to compile and upload the program. You could write a similar program in an PC language.
...R