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.
Published in Tutorials
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 () {}


Published in Tutorials
Tuesday, 15 October 2013 23:27

Arduino通过74HC595扩展IO

 

74HC595是一个价格廉宜的8位移位寄存器,通过3个数据引脚(STCP, SHCP, DS),可以控制几乎无限量的输出。

DS是一个串行数据输入端,每当时钟输入(SHCP)上升沿到来时DS引脚当前电平值在移位寄存器中会移一位,连续进行8次同样的动作,就可以完成全部(Q0至Q7)移位。最后当STCP(Latch)上升沿到来时,移位寄存器的值将会被锁定在存储器里,并从Q0至Q7引脚输出。

Arduino UNO只有14+6个数字输出,如果需要更多的输出,其中之一的方法就是通过74HC595来取得更多的输出。 

Published in 电子与电脑
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);
}

 

 

Published in Tutorials
Wednesday, 25 September 2013 18:40

Using 74HC595 Shift Registers with Arduino

The 74HC595 is a very handy IC used in many microcontroller projects, it is a 8-bit serial-in, serial/parallel-out shift register with output latches.
 
Data is shifted on the positive-going transitions of the shift register clock input (SHCP). The data in each register is transferred to the storage register on a positive-going transition of the storage register clock input (STCP).
 
The shift register has a serial input (DS) and a serial standard output (Q7S) for cascading. Data in the storage register appears at the output whenever the output enable input (OE) is LOW.
 
This is incredibly helpful if you need more digital outputs then the 14+6 that the ATmega328 on the Arduino Uno provides, with only 3 data pins, you can control an almost unlimited amount of outputs.
 
Upon completion of this tutorial, you should be able to controlling the 74HC595 as below:
  • Using 74HC595 Shift Registers with Arduino
  • Daisy chaining 74HC595 shift registers
  • Different ways (binary, decimal, hex) to hold the data using an array
  • Using bitshift, bitwrite operators
  • Direct port access for faster manipulation of the IO pins 
Published in Blog
Saturday, 17 August 2013 16:51

Minimal Arduino with 8MHz internal clock

Build your own DIY Arduino board with only one passive component, it is very easy and simple. This is probably the most minimal ATmega328 based Arduino.
 
Part list
  • ATmega328
  • 28 pins IC socket
  • 10K resistor
  • Strip board 
Published in Projects
This is a tutorial shows you how to build your own Arduino, I name it as SalMonDuino which is derive from my name (SM Ching). SalMonDuino is an modified version of original post written by Serisman, features include:
  • Using stripboard eliminate the trouble of drilling PCB holes
  • Simple circuit design uses minimum of components
  • Using 16MHz resonator as clock source
  • Prototype area
Published in Projects
Aarduino communicate with Vixen
Vixen is a free and popular light show creator software. With a PC and some hardware, anyone can have a professional-looking lighting display synchronized to music.
 
The latest version is Vixen3, the most attractive feature is supported for preview. Compare to Vixen2, Vixen3 is a bit difficult to use & lack of some features in Vixen2. Please correct me if I'm wrong.
 
This tutorial is based on Vixen2, please download Vixen2 and install it to your computer. Prior to Vixen2, you must have install Microsot.NET Framework 2.0 in your computer.
Published in Blog
Saturday, 29 June 2013 16:25

Arduino电子密码锁

一个基于Arduino微控制器的密码锁,一般上用于防盗门。为了方便初学者学习与操作,这里提供了两个版本的电子密码锁源码。
 
读完文章与明白程序操作后,你将会如何应用:
  1. EEPROM字串存取
  2. 运用#include文件,把谋些函数(function)调去外部文件
  3. 简单的旋律处理
  4. 日期与时间处理
  5. 如何形成Press and hold
  6. 矩阵键盘应用与空闲(idle)侦察
  7. 密码处理与验证
  8. i2c LCD
  9. 非阻塞编程(Non blocking programming) 
Published in 电子与电脑
Saturday, 01 June 2013 11:44

Digispark红外接收器

Digispark Infrared Receiver
Digispark是一个基于ATTINY85微控制器且具備USB接口的开发板,使用Arduino IDE开发,编程与Arduino极相似。这里介绍如何利用家里的红外遥控器配合Digispark遥控设备。
 
Digispark是Digistump LLC (digistump.com)版权所有,请使用者仔细阅读Digispark使用协议和版权声明
 
Published in 电子与电脑
Back to Top