Sunday, 08 February 2015 21:09

Arduino电子排队叫号机

这是为谋诊所设计的排队叫号机,计数器只需显示两位数。此叫号机使用了两片Arduino,一个安置在房内用来输入编号,称之为发送器,另一个则安装在房外,用来显示编号,称之为接收器。发送器是通过串口发送信息给接收器。

发送器连接了一个PS2键盘来完成输入,当然也可以使用USB键盘,不过必须添加一个USB Host Shield,这样将会增加成本。如果没办法取得PS2键盘,建议使用矩阵键盘。发送器也应用了一个小型LCD,用于显示编号,当然还能显示更多的相关资料。

接收器用了一片32x16像素的矩阵LED单元板,用来显示从串口取得的相关数据。接收器也安装了一个“铃铛”报知器,每当接收到来自发送器的数据,都会温馨提醒一下。

Published in 电子与电脑
Sunday, 12 October 2014 15:12

Using HEF4094 Shift Registers with Arduino

I have many seven segment modules in my hand. Each module consists of 5 digits and each digit is controlling by individual HEF4094 shift register. As shown in figure above is the seven segment module.

HEF4094 is an 8-stage serial shift register. Data is shifted on the LOW-to-HIGH transitions of the CP (Clock) input. The product data sheet is available here.

HEF4094 operates over a recommended VDD power supply range of 3 V to 15 V referenced to VSS (usually ground). There is also 74HC4094 available which operates at 2V to 6V.

Published in Blog
Friday, 04 July 2014 13:54

Arduino based RGB Matrix LED tester

Arduino based RGB Matrix LED tester

This is a very simple Arduino project which control the 16x32 RGB LED Matrix Panel via an 16pin IDC cable. The Arduino will continuously sending 5 set colours (Red, Green, Blue, White, Black)  to the LED Matrix Panel that allow the technician to find out which part of the LED Matrix Panel is malfunction.

Published in Projects
Saturday, 15 February 2014 20:38

Wireless Router Remote Control Car

This is my first RC car control by an Arduino and a wirless router running OpenWRT. There are many OpenWRT supported routers, I'm using a TP-Link TL-MR3020 3G/4G Wireless N Router for this project since it is very slim, low power consumption and it is cheap.

 

RC car features

  • A webcam, the car can be driven without line of sight
  • A horn so that you can honk at people.
  • LED Headlights attached to the front of the car
  • Two wheel drive motor
  • Windows GUI application or web interface
  • Future Additions: Control by a smartphone (Android & IOS)
Published in Projects
Count number of digits in a number(integer). Eg. countDigits(5678) return 4
  1. byte countDigits(int num){
  2. byte count=0;
  3. while(num){
  4. num=num/10;
  5. count++;
  6. }
  7. return count;
  8. }
 
 
Extract a digit from an number(integer). Eg. getDigit(5678,2) return 6
  1. int getDigit(unsigned int number, int digit) {
  2. for (int i=0; i<digit-1; i++) {
  3. number /= 10;
  4. }
  5. return number % 10;
  6. }
 
 
Extract all digits from a number and store them to an array
  1. #define MAX_NUMBER_OF_DIGITS 5
  2. byte array_to_hold_digit[MAX_NUMBER_OF_DIGITS];
  3.  
  4. void setup(void) {
  5. Serial.begin(9600);
  6. extractDigit_Save2Arrary(5678);
  7. Serial.println(array_to_hold_digit[0]);
  8. Serial.println(array_to_hold_digit[1]);
  9. Serial.println(array_to_hold_digit[2]);
  10. Serial.println(array_to_hold_digit[3]);
  11. }
  12.  
  13. void loop(void) {
  14.  
  15. }
  16.  
  17. /*----------------------------------------------------------------------------
  18.  count number of digits in a number(integer)
  19. ----------------------------------------------------------------------------*/
  20. void extractDigit_Save2Arrary(int number){
  21. byte number_of_digit = countDigits(number);
  22. for (byte i=0; i<number_of_digit; i++) {
  23. array_to_hold_digit[i] = getDigit(number,number_of_digit-i); //store each digit to array
  24. }
  25.  
  26. /*
  27.   for (byte i=0; i<number_of_digit; i++) {
  28.   Serial.print(array_to_hold_digit[i]);
  29.   }
  30.   Serial.println();
  31.   */
  32. }
  33.  
  34. /*----------------------------------------------------------------------------
  35.  count number of digits in a number(integer)
  36. ----------------------------------------------------------------------------*/
  37. byte countDigits(int number){
  38. byte count=0;
  39. while(number){
  40. number=number/10;
  41. count++;
  42. }
  43. return count;
  44. }
  45.  
  46. /*----------------------------------------------------------------------------
  47.  extract a digit from an number(integer)
  48. ----------------------------------------------------------------------------*/
  49. byte getDigit(unsigned int number, int digit) {
  50. for (int i=0; i<digit-1; i++) {
  51. number /= 10;
  52. }
  53. return number % 10;
  54. }
 
 
Published in Tutorials
Saturday, 21 December 2013 22:21

Debouncing Multiple Switches

If you want to input a manual switch signal into a digital circuit you'll need to debounce the signal so a single press doesn't appear like multiple presses. 
 
There is a Bounce library for Arduino which is very easy to use. However there is limitations with this Bounce library.
  • You are unlikely to enable the internal pull-up resistor on switch pins, therefore each switch require an external pull-up resistor
  • It is not possible to detect the switch state before main loop (setup). When you press a switch during power on, you will never get the state of the switch.
Published in Tutorials
Tuesday, 17 December 2013 21:51

Arduino function with optional argument(s)

Function Declaration and Function Prototypes: function prototype allowing the function to be used before it is defined.
functionReturnType myFunctionName(optionalArgumentType optionalArgument = defaultValue);
 
Function Implementation

functionReturnType myFunctionName(optionalArgumentType optionalArgument);
{
   // put your code here
}

 
Function calls

myFunctionName(); // Use the default value
myFunctionName(1); // Use specific value

 
Example
  1. int myFunction(int optionalArgument = 1);
  2.  
  3. void setup() {
  4. Serial.begin(9600);
  5. }
  6.  
  7. void loop() {
  8. Serial.println(myFunction()); // Use the default value
  9. Serial.println(myFunction(2)); // Use specific value
  10. }
  11.  
  12. int myFunction(int optionalArgument)
  13. {
  14. return optionalArgument;
  15. }
 
Published in Tutorials
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
Published in Tutorials
Tuesday, 05 November 2013 20:36

Sharp GP2Y0A21红外线测距传感器

Sharp GP2Y0A21是一颗红外线测距传感器,易于使用,价钱廉宜,且低功耗。 规格如下:
  • 距离测量范围:10至80cm(4“到32”)
  • 工作电压:4.5V至5.5V
  • 输出类型:模拟电压
  • 平均功耗:35mA
  • 峰值功耗:约200mA
  • 允许的最大角度:> 40°
  • 更新频率/周期:25 Hz/40毫秒
Published in 电子与电脑
Sunday, 03 November 2013 17:49

Sharp GP2Y0A21 IR distance sensors

Sharp GP2Y0A21 is an infra-red distance measuring sensor unit,  it is extremely effective, easy to use, very affordable and has low power consumption. specification as follow:

  • Distance measuring range: 10 to 80cm (4" to 32")
  • Operating voltage: 4.5V to 5.5V
  • Output type: Analog voltage
  • Average power consumption : 35 mA
  • Peak power consumption : about 200 mA
  • Output voltage differential over distance range: 1.9V 
  • Maximum allowable Angle : > 40 °
  • The frequency of updates/cycle : 25 Hz/40 ms
Published in Blog
Back to Top