The breadboard.zip hardware configuration archieve is not working on Arduino software version 1.0 and above
 
Here is my boards.txt setup for ATMega328 which is working on version 1.0 and above
Modify the file ...\your_arduino_folder\hardware\arduino\boards.txt by adding these few lines:

##############################################################
atmega328bb.name=ATmega328 Optiboot (8MHz internal clock)
atmega328bb.upload.protocol=arduino
atmega328bb.upload.maximum_size=30720
atmega328bb.upload.speed=57600
atmega328bb.bootloader.low_fuses=0xE2
atmega328bb.bootloader.high_fuses=0xDA
atmega328bb.bootloader.extended_fuses=0x05
atmega328bb.bootloader.path=arduino:optiboot
atmega328bb.bootloader.file=optiboot_atmega328.hex
atmega328bb.bootloader.unlock_bits=0x3F
atmega328bb.bootloader.lock_bits=0x0F
atmega328bb.build.mcu=atmega328p
atmega328bb.build.f_cpu=8000000L
atmega328bb.build.core=arduino
atmega328bb.build.variant=standard

 
And here is the boards.txt setup for ATMega8

##############################################################
atmega8noxtal.name=ATmega8 Optiboot (8MHz internal clock)
atmega8noxtal.upload.protocol=arduino
atmega8noxtal.upload.maximum_size=7168
atmega8noxtal.upload.speed=38400
atmega8noxtal.bootloader.low_fuses=0xe4
atmega8noxtal.bootloader.high_fuses=0xc4
#atmega8noxtal.bootloader.path=atmega8_noxtal
atmega8noxtal.bootloader.path=optiboot
atmega8noxtal.bootloader.file=optiboot_atmega8.hex
atmega8noxtal.bootloader.unlock_bits=0x3F
atmega8noxtal.bootloader.lock_bits=0x0F
atmega8noxtal.build.mcu=atmega8
atmega8noxtal.build.f_cpu=8000000L
atmega8noxtal.build.core=arduino
atmega8noxtal.build.variant=standard

 
Note: Do not modify the boards.txt in your Arduino sketch folder (eg. ...\My Documents\Arduino\hardware\...boardx.txt), it will not work.
 
 

Using an Arduino board to burn the bootloader
If your ATMega8/ATmega328 already configured to use external clock, then wire up the Arduino board & microcontroller as show in figure 1, otherwise (microcontroller configured to use internal clock) you can follow either figure 1 or figure 2.

Fig. 1 Using an Arduino board to burn the bootloader

 

Fig. 2 Using an Arduino board to burn the bootloader

  • Upload the ArduinoISP sketch onto your Arduino board.
  • From Tools>Board menu, select ATmega328 Optiboot (8MHz internal clock) if you want to burn the bootloader on ATMega328 microcontroller
  • From Tools>Board menu, select ATmega8 Optiboot (8MHz internal clock) if you want to burn the bootloader on ATMega8 microcontroller
  • From Tools>Programmer> menu, select Arduino as ISP
  • Select Burn Bootloader from Tools menu to start burning bootloader to microcontroller
Burning sketches to the Arduino board with an AVRISP MKII programmer without using the bootloader. This allows you to use the full program space (flash) of the chip on the Arduino board. So with an ATmega328, you will get 32KB instead of 30KB of space. It also avoids the bootloader delay when you power or reset your board.
Tuesday, 22 October 2013 22:13

Identify which Arduino bootloader do I have

Here’s an Arduino sketch which tries to identify the bootloader and reports it on the serial port
 
The sample output look like this:
[bootCheck.2]
  CRC 2048b @ 0x7800 = CD70
  CRC 512b @ 0x7E00 = FD70
Boot loader: OptiBoot 4.4
 

// Detect which type of boot loader is present, using a fixed built-in table
// 2012-03-06 <This email address is being protected from spambots. You need JavaScript enabled to view it.; http://opensource.org/licenses/mit-license.php

#include <avr/pgmspace.h>
#include <util/crc16.h>

#define VERSION "2"

// list of all known boot loaders with their unique signatures
struct { word crc; const char* desc; } signatures[] = {
0x489C, "Duemilanove",
0xF1A0, "Nanode (Duemilanove mod)",
0xFD70, "OptiBoot 4.4",
0, 0
};

static word CalculateChecksum (word addr, word size) {
word crc = ~0;
prog_uint8_t* p = (prog_uint8_t*) addr;
for (word i = 0; i < size; ++i)
crc = _crc16_update(crc, pgm_read_byte(p++));
Serial.print(" CRC ");
Serial.print(size);
Serial.print("b @ 0x");
Serial.print(addr, HEX);
Serial.print(" = ");
Serial.println(crc, HEX);
return crc;
}

static const char* IdentifyBootLoader (word addr, word size) {
word crc = CalculateChecksum(addr, size);
for (byte i = 0; signatures[i].desc != 0; ++i)
if (signatures[i].crc == crc)
return signatures[i].desc;
return 0;
}

void setup () {
Serial.begin(57600);
Serial.println("\n[bootCheck." VERSION "]");

const char* message = IdentifyBootLoader(0x7800, 2048);
if (message == 0)
message = IdentifyBootLoader(0x7E00, 512);
if (message == 0)
message = "(UNKNOWN)";

Serial.print("Boot loader: ");
Serial.println(message);
}

void loop () {}


Friday, 27 September 2013 20:40

Arduino BIT manipulations

Code below set third pin to HIGH without changing the state of any of the other pins
bitSet syntax: bitSet(x, n)
  • x: the numeric variable whose bit to set
  • n: which bit to set, starting at 0 for the least-significant (rightmost) bit

//initialized all pins to LOW
byte pinState = B00000000;

//set the third pin high
bitSet(pinState, 2); //pinState = B00000100

 
  
Code below set third pin to LOW without changing the state of any of the other pins
bitClear syntax: bitClear(x, n)
  • x: the numeric variable whose bit to clear
  • n: which bit to clear, starting at 0 for the least-significant (rightmost) bit

//initialized all pins to HIGH
byte pinState = B11111111;

//set the third pin LOW
bitClear(pinState, 2); //pinState = B11111011

 
 
Code below set each pin as LOW or HIGH without changing the state of any of the other pins
bitWrite Syntax: bitWrite(x, n, b)
  • x: the numeric variable to which to write
  • n: which bit of the number to write, starting at 0 for the least-significant (rightmost) bit
  • b: the value to write to the bit (0 or 1)
byte pinState= 0; //initialized all pins to LOW (B00000000)
bitWrite(pinState, 0, HIGH); //set first pin to HIGH, pinState = B00000001
bitWrite(pinState, 3, HIGH); //set third pin to HIGH, pinState = B00001001
bitWrite(pinState, 0, LOW); //set first pin to LOW, pinState = B00001000
 
 
Reads a bit of a number.
bitRead Syntax: bitRead(x, n)
  • x: the number from which to read
  • n: which bit to read, starting at 0 for the least-significant (rightmost) bit

byte pinState = B10101010;
for (int i=0; i<8; i++) {
   theBit = bitRead(pinState, i);
}

 

 

Tuesday, 23 April 2013 12:17

Password access with Arduino using keypad

Arduino and Keypad
This example demonstrates how to use a 4x4 matrix keypad access password from an Arduino. Sketch below required to install password and keypad library, both available at Arduino Playground. Below list the functions of password library:

set(password)
Set the target password equal to password.

is(password)
Is the target password equal to password

append(character)
Append a character to the currently guessed password

reset()
Reset the currently guessed password

evaluate()
Is the guessed password equal to the target password?

Back to Top