Guide to Arduino Beginner's

After some years of experimenting with Arduino, I decided that the time has come to share the knowledge I've acquired. So I here it goes, a guide to Arduino, with the bare basics for beginners and some more advanced explanations for people who are somewhat more familiar with electronics. Every step will consist of a detailed explanation, then a summary, followed by a more advanced approach. If you're a complete beginner, I recommend reading the explanation first, and then the summary. There will (almost certainly) be some parts of the explanation you don't understand. Don't worry, it is absolutely normal, it will become clear after reading some other examples in the next steps, just don't get discouraged!

I'll provide some links to the Arduino reference page, Wikipedia, and some other interesting sources. If you want to know more about about a certain subject, these are great places to start. Again, if you don't understand a word of those links, don't worry, it is absolutely not necessary for this Casino Digital Tech, and especially for beginners, they can be very confusing or even demotivating. If that's the case, it might be better to skip them for now. But don't give up!

Although a tutorial like this might be very helpful, you'll learn mostly by experimenting yourself. Use this lesson as a starting point, as a reference, but make your own projects, modify the given examples, try new things, search the internet, the possibilities are pretty much endless!


Well, first things first: What is Arduino?
Let's take a look at the introduction from the Arduino website:

Arduino is an open-source prototyping platform based on easy-to-use hardware and software. Arduino boards are able to read inputs - light on a sensor, a finger on a button, or a Twitter message - and turn it into an output - activating a motor, turning on an LED, publishing something online. You can tell your board what to do by sending a set of instructions to the microcontroller on the board. To do so you use the Arduino programming language (based on Wiring), and the Arduino Software (IDE), based on Processing.

That actually says it all.
You can find the complete introduction here.

Maybe a little more information about the board:

The Arduino Board itself is a blue circuit board, the size of a credit card (but they also have models in other sizes). It has two rows of connectors (the 'headers'), a power connector and a USB connector. The brain of the board is an Atmel microcontroller. It's like a really small, very low power 'computer'. (It only has 32KB of storage, 2KB of RAM, and the 8-bit processor runs at only 16MHz.) For most applications, however, this is more than enough. The pins of the processor connect to the headers, and you can connect them to virtually anything you can imagine. You just need to write some lines of code to control them. The I/O pins (Input/Output) can be used as input pins, to connect buttons or knobs, temperature sensors, light sensors, or even keyboards and mouses, digital musical instruments … or they can be used as output pins, to connect LEDs, drive motors, control the lights in your home, connect to small displays or even connect to the Internet, so that it can check your mail, post tweets ... Through the USB connection you can also use it to control your computer, or use your computer to control the Arduino.

As you can see, the sky's pretty much the limit !

You can buy an Arduino from their website or from a local reseller for about $22 (€20).

To get an idea of what you can do with an Arduino board, check out the Arduino blog or the Arduino channel here on Casino Digital Tech.


Before You Begin...

How not to fry your Arduino

Before you begin plugging things into your new Arduino, it may be good to know what can damage the board.

  1. Drawing more than 40mA from an output pin.
    An Arduino can only supply 40mA per output pin, so you cannot drive a motor or a speaker directly, for example, and you cannot connect an LED directly (without a resistor). In the course of this Instructable, I'll explain what you should do instead.
    Shorting an output in to the +5v, +3.3v or the ground pins, will also kill your board: If an output pin is at 5v for example, and you connect it to the ground, it draws an enormous amount of current, and kills your Arduino almost instantly.
    The pins go through the circuit board, so make sure you don't place the Arduino on a conductive (metal) surface, because it will short out the pins.
  2. Drawing more than 200mA from all output pins together.
    The ATmega chip on your Arduino can only supply 200mA in total, so driving more than 10 LEDs @ 20mA each, for example, will eventually damage your board.
  3. Supplying more than 5v (3.3v) to an input pin.
    Supplying more than the operating voltage of the Arduino on any pin is very dangerous. Some Arduinos that run at 3.3v have 5v tolerant pins, but that's about it. This also holds true for other devices, like sensors or wireless chips: always check the voltages: if you connect the output of a 5V Arduino to a 3.3V chip, you might kill it.
  4. Supplying more than 5v to the 5v pin.
    The 5v of the Arduino board goes directly to the ATmega chip, that is rated for an absolute maximum of 6v.
  5. Supplying more than 12v to the Vin pin.
    There's an onboard 5v voltage regulator on the board, that will overheat and die if you feed it with more than 12v.
  6. Drawing more than 500mA from the 5v pin (when running off an external power supply.
    The onboard 5v voltage regulator can only supply 500mA of current. The 5vUSB has a polyfuse to limit the current to 500mA.
  7. Drawing more than 50mA from the 3.3v pin.
    The onboard 3.3v voltage regulator can only supply 50mA of current. This means that you can not connect power hungry 3.3v devices like an ESP8266 or nRF24L01 directly to the Arduino: you need an external 3.3v voltage regulator.
  8. Reversing the polarity of the power supply.
    If you swap the 5v or Vin pin with the GND pin, you'll kill the board almost instantly.
    The barrel jack has a diode to protect against reverse polarity.
  9. Connecting a load to the Vin pin while using USB power.
    If you connect a load to the Vin pin while the 5v to the Arduino comes from the USB connection, current will flow backwards through the voltage regulator, damaging it.
  10. Static electricity
    Although most chips have clamping diodes as protection against ESDs (electrostatic discharges), it may be wise to us an anti-static wrist strap, or to remove the carpet under your desk.

Arduino IDE

For programming our Arduino, we'll need the Arduino IDE (integrated development environment).
It can be downloaded from the site.

Windows:

  • Go to the site, go to Download, and select the Windows installer.
  • Consider donating some money, if you want to support the project, and click download.
  • Click the downloaded file to run it.
  • Grant administrator permission.
  • Agree to the License Agreement.
  • Select the appropriate boxes, you'll need the Arduino Software and the USB driver, the other three are optional.
  • Accept the default installation folder, or pick another one. Then click install.
  • When you're prompted whether or not you want to install the Arduino USB Driver (device software), click install.
  • Wait for the installer to complete, and launch the Arduino IDE.

(A complete installation guide can be found on the Arduino website as well.)

  • Go to the site, go to Download, and select the right Linux version.
  • Consider donating some money, if you want to support the project, and
  • click download.
  • Open a terminal window (CTRL+ALT+T), and run these commands, changing the filename appropriately
  • cd Downloads
  • tar xf arduino-1.6.11-linux64.tar.xz
  • sudo mv arduino-1.6.11/ /opt/arduino-1.6.11/
  • /opt/arduino-1.6.11/install.sh
  • sudo usermod -a -G dialout $USER

This goes to the Downloads folder, unzips the downloaded file, moves it to the /opt/ folder, and runs the install script. This install script will create a desktop file, and a MIME type to associate .ino files with the Arduino IDE. Finally, you have to add (-a = append) your user to the 'dialout' group (-G), in order to have access to the serial ports. ($USER is a system variable for the current user) If you open the Arduino IDE now, you'll see that the Tools > Port option is grayed out. When your user is added to the dialout group, log out, and sign back in. Your Arduino's serial port should now be available in the IDE.

Arduino IDE + Teensyduino

If you have a Teensy board, you'll need the Teensyduino add-on for the Arduino IDE. The installation is very simple, and a very good install guide can be found on the Teensy site.

Teensyduino currently doesn't support the latest versions (1.6.10 & 1.6.11 @07-09-2016) of the Arduino IDE yet, so you'll have to download a previous version. (1.6.9)

If you're running Linux, you may come across this error while installing Arduino:

bash: /opt/arduino-1.6.6/install.sh: Permission denied

If this is the case, try running

sudo chmod +x /opt/arduino-1.6.6/install.sh

This adds (+) the permission to be executed (x). Then try running /opt/arduino-1.6.6/install.sh again.

Example sketches

I added a .ZIP file with all the example sketches I'll be using throughout this Instructable, download and unzip it so you can follow along, or even modify them to your own needs if you want to.

Download the Zip file for Basic Examples and Code here
Share:

No comments: