📜 ⬆️ ⬇️

Arduino: first acquaintance

A month ago, I ordered a toy called Arduino. This is a set of “cubes” from which any kettle can assemble a working device without a soldering iron, etching printed circuit boards and other “black magic”. In general, this is such a constructor for professional prototyping as well as for various amateur experiments.

A month after the order I received a parcel with the Arduino, more precisely, its variation - Seeeduino. That's what it was:


From left to right / top to bottom:

Black and white graphic LCD display, 128 * 64 (ST7565 / 67 ctrl)
Serial port bluetooth module (slave)
A pair of joysticks - a small 4-position and large analog Playstation2 analog joystick
Seeeduino Mega - actually a mini-computer itself, and to the right of it is a set of attached “combs”
A pair of some green boards, a breadboard, a set of 20 mini-buttons
See “Seeeduino Catalyst Pack” for details (what is included in this kit can be found here )
A wiring kit for a breadboard
A package with parts for connecting the Krona battery or power supply unit
USB / miniUSB cable
')
Why do I need all this wealth? A wearable computer requires non-standard devices, such as, for example, a chord keyboard. You can, of course, order the three hundred-dollar Twiddler2 from the States (or it is already impossible - it seems they stopped producing them). And you can - with the help of Arduino try to independently make a similar device, at the same time trying to find a more convenient solution. In addition to the chord keyboard, I would like to get a wireless text display (so that the head-on display works via bluetooth, not by wire), as well as wireless biometric sensors. Moreover, the network has instructions for assembling the simplest pulse sensors based on the Arduino. There are thousands of Arduino projects of various levels in the network - this designer has gathered around him a large audience of enthusiasts.

Arduino is an open platform. Each, if desired, and with the appropriate qualifications, can take up the issue of such “cubes” and sell them. But in order to sell them "under the label" Arduino, you need to get certified. However, no one bothers to make minor changes to the design and sell their devices under a different name. As a result, Arduino clones of varying degrees of compatibility appeared - Seeeduino, Freeduino and others. All of them are collected on the basis of the ATmega microcontroller family. Different models of these microcontrollers differ from each other in speed, RAM / PROM volume and, of course, price. I bought Seeeduino Mega based on one of the most powerful processors used in the Arduino - ATmega1280.

To start working with Arduino, you need to install on your computer the development environment - Arduino IDE. Since it is written in Java, it works under Linux, and under Windows, and under Mac OS. Download this program and familiarize yourself with the installation instructions on the Ardiono official website: www.arduino.cc/playground/Main/DevelopmentTools

Installation under Linux

I have a netbook - Eeebuntu (Jaunty Jackalope). Java is already installed. After reading some rather vague instructions for installing software, I did the following just in case:

1) In /etc/apt/sources.list append a line
deb archive.ubuntu.com/ubuntu jaunty main restricted universe multiverse

2) Completed:
$ sudo apt-get update
$ sudo apt-get install gcc-avr
$ sudo apt-get install avr-libc

3) I downloaded, unpacked and launched arduino-0018.tgz

Installation under MS Windows XP
(http://arduino.cc/en/Guide/Windows)

Download and unpack the archive with the software. Unlike incomplete 4 megabytes of the Linux distribution, the archive for Windows weighs 87 MB. We connect to the USB port of the Arduino computer. The new hardware installation wizard (or what is it called? Assistant?) Says that you shouldn’t look for a network driver, and specify “the folder where the arduin software \ drivers \ FTDI USB Drivers \” was unpacked as the driver search directory. After the first wizard comes the second - to configure the COM-port. We do the same with the second wizard as with the first, after which we have a computer that can communicate with the Arduino board.

Writing sketches



Programs for Arduino are called sketches. There are different languages ​​for writing sketches. With the Arduino IDE, you can write sketches in a C-like language Processing. If studying C many start with the classic “Hello World!”, Then for Arduino, such a “hello” was a script that blinks an LED. Run the Arduino IDE and type in the window that appears:
 // Determine which leg of the chip will be connected LED
 #define LED 13

 void setup () {
   // Indicate that this leg will be used for output
   pinMode (LED, OUTPUT);
 }

 void loop () {
   // Let's light the LED by applying voltage to the leg
   digitalWrite (LED, HIGH);
   // Wait a second
   delay (1000);
   // Extinguish the LED by removing the voltage from the legs
   digitalWrite (LED, LOW);
   // Wait a second
   delay (1000);
 } 

In this sketch there are two main functions. setup () is performed once at the start of the application, here, as a rule, the modes are set in which the microcontroller legs will work, the data is initialized. loop () runs indefinitely (until the power is turned off). By the way, when you turn off the power, the sketch recorded in the Arduino is not erased. So when you turn on the power, the microcontroller will start the sketch by first running setup () and then looping through loop () cyclically.

Compile the written sketch by pressing the Verify key. . If the script was compiled without errors (the compiler messages are displayed at the bottom, in the black window), upload it to the device. At first we will collect the scheme for which the sketch was written. In our case, we’ll turn on the LED to the Arduino. The cathode of the LED (short leg) is inserted into the Gnd socket, the anode (long leg) into the socket 13.



Now connect the Arduino to the USB connector of the computer and press the Upload key. . The board will flash service lights and begin the sketch.



For mastering the Arduino, you should read the book Massimo Banzi “Getting started with Arduino”. In addition to the paper copy issued by O'Reilly, there is an absolutely legal electronic version of the book, which is easy to google.

Source: https://habr.com/ru/post/82974/


All Articles