Книга: Arduino: Master The Arduino Basics
Назад: Chapter 3: Learning the Arduino Code
Дальше: Install the Drivers

Now it is time to work on learning how to write some of the code that is needed for your board and to test to make sure that the board is working properly. By this time the IDE should be set up, and you have had a bit of time to go through and try out a few of the different sketches that we talked about in the last chapter. But now that we have all of that down, it is time to work with using our board and making sure that it works properly.

If you are still new to programming, you may be looking at the Arduino board and feel a bit worried about how you will proceed. There are a lot of parts that can come with the board, and it may be a bit confusing to get started. But if you have the IDE set up, you will be just fine, and your projects will come to life in no time.

Starting out on your first project is not going to be that difficult. There are a few things that need to be set up before you get going. First, you need to make sure that you have your IDE set up and working. Also, ensure that your computer is able to recognize the Arduino board that you choose to use and then you have to write out the correct code. Once you have these components in place, it is time to start on a project. 

We need to take a moment to look at the coding a bit more because this is often the most complicated part that comes with using the Arduino system. For those who have been able to work with C++ in the past, you will find that the rules for Arduino are going to be pretty simple so this can help out. Don’t fret too much if you haven’t been able to learn C++ in the past. This language is pretty basic, and most of the projects you work on will use a similar approach, so you will catch up fast.

Before we start working on this first project, make sure that the IDE is ready to go. You need it uploaded and turn on the computer so that it will work properly and will recognize the codes that you want. This seems simple, but it is impossible to work on any of the projects that you want if the IDE isn’t even on your computer.

At this point, you should have the hardware in place, and your Arduino IDE set up. We are going to take a moment to test out our program to ensure that it is working properly. This will be the first project that we work with and will test that the board is working and will give you a bit more experience with working in this coding language.

Remember that there are a number of different boards that you can work with when creating a project with Arduino, but for this particular test project, we are going to work with the Arduino UNO or the R3 board. This is one of the most popular boards, so you will find that a lot of different projects will work with this type of board. It is possible to use another board if you would like to make this test project work, but you may need to make a few quick modifications to see it work. In addition to getting the UNO board, you will need the following items

 

Once all of these items are gathered together, and you are ready to work on this project, it is time to start testing out the board. This is a simple project, but it will help you to test out any of the boards that you want to work with and will ensure that you get the coding and the system down for when it is time to work on your own projects.

Plugging in the Board

The first thing that we need to do is get the board plugged in and recognized by the computer. You can easily use the USB cord that was recommended earlier to help you plug this board into the computer, or another power supply will work in some cases. Some people will start by hooking it to a wall to give it some power, but this will not allow you to hook the board with your IDE which means any code you write will not transfer over, so hooking up with the USB cable is usually the best option. Once the coding is moved over to the board, you can choose whether to hook it up to the wall or to the computer.

So, you will need to hook the USB cable up to the right port on the Arduino board and then also hook the other end to the computer. Now that the computer and the board are connected, take a look at your board and see where the ON light is located. If the board is working properly, this light will start blinking quickly. This is known as the default program for the ON light, and it is already placed on a chip inside the board. 

With this project, we are going to override the default program so that instead of getting an LED light that blinks rapidly, it is going to blink on and off with two seconds occurring between your blinks. It isn’t much, but it is a great way for you to get started.

If you look at your board and notice that the ON light is not blinking at all right now, it is time to do some troubleshooting. The first thing to look for is whether the USB cable has been plugged in properly to the machine. Sometimes it is an issue with using the wrong cord. Check to see if these are both right. In most cases, fixing one of these two issues will turn the ON light on, and it will begin to blink for you.

Назад: Chapter 3: Learning the Arduino Code
Дальше: Install the Drivers