Outils pour utilisateurs

Outils du site


issue48:tuto-arduino

Ceci est une ancienne révision du document !


With the Heathkit company gone, and with a modern computer using Ubuntu 10.04 LTS, I found a website detailing a micro-controller named Arduino at www.arduino.cc (not .com). It used a USB cable for power and its computer connection. Arduino Uno was affordable at $30. A simple traffic light simulation on a breadboard seemed just the fun experiment to try. Getting things to work involved just three main tasks: • Installing and configuring the Arduino IDE (Integrated Development Environment), • Figuring out the wiring for the breadboard and the Arduino ports needed, and • Writing a simple C program followed by an upload of the compiled code to the Arduino micro-controller. Task 1 was simple, 2 was routine with some refresher study, and 3 required a small learning curve about C procedures - along with some new commands specific to the Arduino ports. Uploading the compiled code to the micro-controller was easy. Within a few days of fussing with things, my system finally worked as designed. Later, I updated my code to include a buzzer in the circuit.

Part 1: Installing the Arduino IDE (for details see http://arduino.cc/playground/Linux/Ubuntu) I used the “Ubuntu without 'arduino' package” section of the page for my install. (Your installation may vary.) Download the .gtz file, and install it with Archive Manager: aduino-0022.gtz (from http://arduino.cc/en/Main/Software using the Linux 32-bit package) Install the compiler and the libraries packages: sudo apt-get install gcc-avr avr-libc

For those using the USB port to dialog, add yourself to the group 'dialout' to have write permissions at that port with: sudo usermod -aG dialout <your username> Next, to run the application, open the “arduino-0022” folder, right click “arduino” and choose “Run”. Once the IDE is running, select your board (mine was the Arduino Uno) from Tools > Board. Part 2: Wiring the breadboard and connecting it to the Arduino Here are the parts I used to complete the wiring (mostly from Radio Shack):

• breadboard and a few spools of 22-gauge, insulated, solid-core wire • 2.1mm power plug, and 9-volt battery cap (solder red lead to the center tap, black lead to the outside tap) • 9-volt battery • LEDs: 2 red, 2 green, 1 yellow (approx 2.1 mA forward current each. Note the orientation!) • breadboard push button switch • 3VDC Mini Buzzer (Radio Shack 273-0053) • resistors 5-220 Ohm, 2-150 Ohm, 1-10K Ohm (all 1/8 Watt okay) Shown below is the wiring schematic, and a view of my Arduino mounted on a wood frame with the breadboard and the wires. (The Lego board was used to hold things loosely together.)

Part 3: Writing the code using C, and uploading the compiled code to the Arduino Uno After some reading at the Arduino website, and with some borrowed code, the project code was one page in length using gedit. The file was then renamed 'trafficlightsound.pde' inside a folder named 'trafficlightsound' – the name extension and corresponding folder name that the Arduino IDE seemed to require. Clicking in the IDE's start arrow at the left made the application verify and compile the code of 1468 bytes. The source code for the Arduino traffic lights can be found at: http://pastebin.com/ACk9u937 After connecting a USB cable between the computer and the micro-controller, one click on the right arrow on the second row square of the IDE started the upload of bytecode to the microcontroller. Once loaded, the Arduino Uno ran the various lights and buzzer as designed. After disconnecting the USB cable and connecting the 9-volt battery, the project ran independently from the computer. The program will continue to run in a loop until the power is removed.

issue48/tuto-arduino.1305746133.txt.gz · Dernière modification : 2011/05/18 21:15 de fredphil91