Arduino ATmega8: microcontroller for beginners

Cars admin26.02.2020

Technology does not stand still and today car enthusiasts are offered many different options for improving their “iron horses”. One of these is Arduino. This device is a tool used for designing electronic devices. In the case of a car, the design is usually done on the windshield. How to make an on-board computer using Arduino and how to configure it correctly - read this article.

Ideas for a car based on a small board with a small processor - Arduino

Computers have long been a part of our lives. The Arduino hardware platform is one of the latest open source developments that is built on a conventional printed circuit. We will tell you more about how to make different devices for cars using such a board.

Using an Arduino board, you can build a car on-board computer that can:

  • calculate fuel consumption;
  • display information about the antifreeze temperature;
  • calculate the speed of movement, as well as the distance of the trip;
  • remove spent fuel over a certain mileage;
  • determine the motor speed, etc. (the author of the video is the Arduino Tech PTZ channel).

In addition to the Arduino device, you will also need an LCD module, a Bluetooth adapter NS-05, as well as an ELM327 scanner and a 10 kOhm resistor device. Of course, it is necessary to prepare the sound indicator, installation wires and the device body itself.

The assembly procedure is as follows:

  1. First we set up the Bluetooth adapter. You need to solder wires to the pins of the device - to the two lower and upper contacts.
  2. The module itself is connected to the board for configuration; to do this, you need to open the Arduino program >Photo gallery “BK connection diagram”

GPS tracker

To build an Arduino-based GPS tracker, you will need:

  • the board itself, the process is described using the example of the Mega 2560 model;
  • GSM/GPRS module, which will be used to transfer data to the server;
  • as well as an Arduino GPS receiver, in the example we will look at the SKM53 model (the author of the video about making a tracker using the SIM 808 board as an example - Alex Vas channel).

How to connect the circuit:

  1. First, the module is connected to the main board; the default baud rate is 115200.
  2. After connecting, you need to turn on the device and set the same speed for all ports - both serial and software.
  3. The GSM transmitter is connected to pins 7 and 8 on the main chip.
  4. Then the module is configured by entering commands. We will not describe all the commands; they can be found on the Internet without any problems. Let's consider only the most basic ones. AT+SAPBR=3,1, “CONTYPE”, “GPRS” - the command determines the connection type, in this case it is GPRS. AT+SAPBR=3,1,“APN”,“internet.***.ru”, where *** is the address of the mobile network operator that will be used. AT+HTTPINIT - this command initializes HTTP.
  5. One nuance should be noted - when writing the server component of the interface, it is advisable to provide for receiving and outputting data for several adapters. You need to set the switch to three positions, this will make it possible to receive data from eight cars.
  6. Then the sketch is written on the microcircuit. The sketch itself can also be found on the Internet; it is not necessary to write it. Please note that if two active serial ports are used, this may lead to errors in the transmission and sending of information.

Parktronic

To build a parking sensor, you will need the following components:

  • the chip itself;
  • ultrasonic device, in this case it is the HC-SR04 rangefinder:
  • six LED elements;
  • six resistor elements with a resistance of 220 Ohms;
  • male-to-male connecting wires;
  • piezodynamic element;
  • layout diagram for assembly.


Elements for assembling parking sensors on Arduino

The build procedure is as follows:

  1. To begin with, you need to install LED elements prepared in advance on the breadboard circuit. The negative contact of all LEDs will be common. The short contact - the cathode - should be connected to the negative bus, which is located on the breadboard.
  2. To the longer contacts of the diodes, that is, the anodes, you need to connect 200 Ohm resistor elements; if you do not use them, this will lead to the diodes burning out.
  3. An ultrasonic device is installed on the central part. There are four pins on this controller. Vcc is the five volt power pin, Echo is the output pin, Trig is the input, and GND is ground.
  4. After the rangefinder is installed, wiring should be connected to its outputs. In particular, the Echo pin is connected to output 13, Trig - to pin 12. GND, accordingly, needs to be connected to the ground, which is available on the controller circuit, and the remaining Vcc output is connected to the 5-volt power supply on the Arduino board.
  5. After completing these steps, you need to connect the wiring to the contacts of the resistor elements. They are also connected in series to pins on the board - pins 2 to 7 are used.
  6. The next step will be to connect a piezo beeper, which will warn the driver when approaching an obstacle. The negative output, as an option, can be combined with the negative contact of a previously installed rangefinder. As for the positive contact, it connects to pin number 11 on the chip.
  7. In order for the device to ultimately operate in normal mode, you will additionally need to write and then load the program code into the board. In this code, it is necessary to accurately indicate the distance, when approaching which the diode elements will light up and the buzzer will be activated. Moreover, the tone of the beeper should be different so that the driver can know when approaching an obstacle will be critical. The code itself is either written independently, or a ready-made version is taken from the Internet. There are a lot of sketch options, you just need to choose the most suitable one for your device (the author of the video is the Arduino Prom channel).

Accessories

To create a vending machine using Arduino, we will need a number of components.

Equipment

  • Arduino Mega
  • Lazercut vending machine × 1
  • TFT LCD 2.8″ × 1
  • Servo × 4
  • Coin acceptor × 1
  • 12V/1A power supply × 1
  • 5V/1A power supply × 1
  • Wire × 1

Software

  • Arduino IDE

Hand tools

  • Dremel engraver

Adding ATmega devices

There is one nuance when working with this chip - we need to make some changes to one file so that we can further program the Arduino ATmega8 microcontrollers.

We make the following changes to the file hardware/arduino/boards.txt :

atmega8o.name=ATmega8 (optiboot 16MHz ext) atmega8o.upload.protocol=arduino atmega8o.upload.maximum_size=7680 atmega8o.upload.speed=115200 atmega8o.bootloader.low_fuses=0xbf atmega8o.bootloader.high_fuses=0xdc atmega8 o.bootloader.path =optiboot50 atmega8o.bootloader.file=optiboot_atmega8.hex atmega8o.bootloader.unlock_bits=0x3F atmega8o.bootloader.lock_bits=0x0F atmega8o.build.mcu=atmega8 atmega8o.build.f_cpu=16000000L atmega8o.build.core=arduino: arduino atmega8o. build.variant=arduino:standard ########################################### ################### a8_8MHz.name=ATmega8 (optiboot 8 MHz int) a8_8MHz.upload.protocol=arduino a8_8MHz.upload.maximum_size=7680 a8_8MHz.upload.speed= 115200 a8_8MHz.bootloader.low_fuses=0xa4 a8_8MHz.bootloader.high_fuses=0xdc a8_8MHz.bootloader.path=optiboot a8_8MHz.bootloader.file=a8_8MHz_a4_dc.hex a8_8MHz.build.mcu=atmega8 a8_8MHz.build.f _cpu=8000000L a8_8MHz.build.core =arduino a8_8MHz.build.variant=standard ############################################ ##################### a8_1MHz.name=ATmega8 (optiboot 1 MHz int) a8_1MHz.upload.protocol=arduino a8_1MHz.upload.maximum_size=7680 a8_1MHz.upload. speed=9600 a8_1MHz.bootloader.low_fuses=0xa1 a8_1MHz.bootloader.high_fuses=0xdc a8_1MHz.bootloader.path=optiboot a8_1MHz.bootloader.file=a8_1MHz_a1_dc.hex a8_1MHz.build.mcu=atmega8 a8_1MHz.build.f_ cpu=1000000L a8_1MHz.build .core=arduino a8_1MHz.build.variant=standard ######################################## ######################### a8noboot_8MHz.name=ATmega8 (no boot 8 MHz int) a8noboot_8MHz.upload.maximum_size=8192 a8noboot_8MHz.bootloader.low_fuses=0xa4 a8noboot_8MHz .bootloader.high_fuses=0xdc a8noboot_8MHz.build.mcu=atmega8 a8noboot_8MHz.build.f_cpu=8000000L a8noboot_8MHz.build.core=arduino a8noboot_8MHz.build.variant=standard

Thus, if we go to the menu Service → Board , we will see the devices:

  • ATmega8 (optiboot 16MHz ext)
  • ATmega8 (optiboot 8 MHz int)
  • ATmega8 (optiboot 1 MHz int)
  • ATmega8 (no boot 8 MHz int)

DIY Arduino

Atmega2560 is a powerful and advanced controller, but it’s easier and faster to assemble your first board based on atmega8 or 168.

The left side of the diagram is a USB communication module, in other words, a USB-UART/TTL converter. It, together with the harness, can be removed from the circuit to save space, assembled on a separate board and connected only for firmware. It is needed to convert signal levels.

DA1 is the L7805 voltage regulator. As a basis, you can use a whole range of avr chips that you will find, for example, series, arduino atmega32 or assemble an arduino atmega16. To do this, you need to use different bootloaders, but for each of the MKs you need to find your own.

You can do it even simpler and assemble everything on a solderless breadboard, as shown here, using the 328th Atmega as an example.

Microcontrollers are easy and fun - you can make a lot of cool and interesting things or even become a great inventor without any education or knowledge of low-level languages. Arduino is a step into electronics from scratch, which allows you to move on to serious projects and study complex languages, such as C avr and others.

Connection diagram

Next we are going to connect the Arduino Mega to the servos and the coin machine, and then test our vending machine. It's best to wire up the entire system outside of the cabinet first to make sure everything works before putting all the parts into the vending machine.

Below you can download the schematic file for the Fritzing program:

Assembling parts

You can order the Venduino body kit through Ryan Bates' website (https://www.retrobuiltgames.com/diy-kits-shop/venduino/) and the LCD screen cover through thingiverse.com (https://www. thingiverse.com/thing:3306469). Creating a housing for a vending machine from a kit is quite simple - follow the photographs that come with the kit or on the website.

There is one customization we are going to do for the 2.8 inch TFT LCD screen, the original screen size is much smaller than our LCD screen. So use a hand tool to cut a 2.35″ by 1.75″ square around the original hole that will fit our TFT LCD screen.

Next we need to create the wire spools that hold the items in the vending machine. You can use decorative wire because it is easy to work with. Next, take a cylinder (slightly smaller than a can of cola) and wrap the decorative wire around it six times. Then we cut the wire. Use the remaining pieces to attach decorative wire to the servo (see photo below).

Rating
( 2 ratings, average 4.5 out of 5 )
Did you like the article? Share with friends:
Для любых предложений по сайту: [email protected]