I will present how to use a microcontroller Atmega162 with Arduino IDE.
I wrote this post as a complement to post AVR / STC51 Dev Board (FKECL PCB). But the information here may be used without the development board.
So if we install an Atmega162 microcontroller on the development board above, we can use Arduino IDE.
1. In the <arduino>\hardware\arduino\avr\boards.txt file, add these lines:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
############################################################## atmega162.name= ATmega162 atmega162.upload.protocol=arduino atmega162.upload.maximum_size=14336 atmega162.upload.speed=57600 atmega162.bootloader.low_fuses=0xFF atmega162.bootloader.high_fuses=0xD8 atmega162.bootloader.extended_fuses=0xFB atmega162.bootloader.path=optiboot atmega162.bootloader.file=optiboot_atmega162.hex atmega162.bootloader.unlock_bits=0x3F atmega162.bootloader.lock_bits=0x0F atmega162.build.mcu=atmega162 atmega162.build.f_cpu=16000000L atmega162.build.core=arduino atmega162.build.variant=atmega162 ############################################################## |
2. Make a folder
[<arduino>\hardware\arduino\avr\variants\atmega162\]
in this folder save file [pins_arduino.h]
3. We will overwrite the file iom162.h in folder
[<arduino>\hardware\tools\avr\avr\include\avr\] with the file attached here: iom162.h
4.File [optiboot_atmega162.hex / optiboot_atmega162.zip] will be saved to:
[<arduino>\hardware\arduino\avr\bootloaders\optiboot\]
Here’s a sample code to use a 16×2 display.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
//------------------------------------------- // include the library code: #include <LiquidCrystal.h> /* * LCD RS pin to digital pin 8 * LCD Enable pin to digital 19 * LCD D4 pin to digital pin 31 * LCD D5 pin to digital pin 32 * LCD D6 pin to digital pin 33 * LCD D7 pin to digital pin 34 * LCD R/W pin to ground ... in this case digital pin 9 -> LOW */ // initialize the library with the numbers of the interface pins LiquidCrystal lcd(8, 19, 31, 32, 33, 34); const int RWPin = 9; void setup() { // set the digital pin as output: pinMode(RWPin, OUTPUT); // R/W Pin to ground digitalWrite(RWPin, LOW); // set up the LCD's number of columns and rows: lcd.begin(16, 2); // Print a message to the LCD. lcd.setCursor(0,0); lcd.print("Arduino"); lcd.setCursor(0,1); lcd.print("atmega162"); } void loop() { } //------------------------------------------- |
Arduino code: DS18x20_Lcd.zip
Arduino code: Led7Segment.zip
Arduino code: Atmega162_Led7Segments_DS18B20.zip