Building More Electronics (Programming an Arduino)

Old No Comments on Building More Electronics (Programming an Arduino) 132

    This is the third installment of my “Electronics” series. You can download and install the Arduino IDE (so you can program the Arduino to some really cool things, including making a floppy drive play music) at The Arduino programming language is C/C++ based. You will need the USB cord to program the Arduino.






Now that your Arduino is plugged in and ready to go, you should make sure that the Arduino IDE (Integrated Development Environment) is operational.










The window that opens after the startup screen should look like the image above. This is the Arduino IDE. This will allow you to program your Arduino so it can be more interactive then just pressing a button, and a light turns on. For people who already know a programming language it will be easier to learn another, since you already know what an if statement is. You just need to learn the exact syntax of the language as opposed to someone new to programming who will also have to learn what an if statement is in the first place. If you have no programming language experience I would recommend that you go and spend a few hours learning a user-friendly programming language like Python (I would recommend that to anyone, even if you were not curious about the Arduino).

In Arduino programming there are two functions that must be called, setup( ) and loop( ). The setup( ) function tells the Arduino how it should start behaving ounce the program starts; how it should initialize. The loop( ) function is will run as soon as the setup() function is done and will continuously repeat and tells the Arduino what to do forever (until you turn it off).

Above is the syntax for the declaration of the setup( ) and loop( ) functions (“void” is in the declaration of a function with no return value (actually had to look that one up)). To make a comment put two slashes (//) and the rest of the line will be a comment. Comments, like in other programming languages, are not run by the computer and are only to help any human reading the code understand the code’s purpose. You can also create variables; you can use if statements, you can see if there is any electrical input on a pin on the Arduino, or make pins on the Arduino give 5 Volts. After every statement, there must be a semicolon.

You can then verify your code by clicking the checkmark button located on the row of buttons above the code to check for errors in your code. If your code is fine, then you upload it to the Arduino with the button with an arrow pointing to the right.

If you wish to learn more about Arduino programming I recommend the Arduino website, They even have a blog and a community. Did I mention that Arduino is Open Source?


Related Articles

Leave a comment

Back to Top