
admin
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)
PicShow component: Image Transition Effects for RAD Studio XE5

- Image transition can be controlled programmatically
- Image can be stretched or centered in the client area of the control
- Control can show a background image as centered, stretched, or tiled
- Transition process can use a separate thread
- New transitional effects can be easily implemented and added.
Count number of digits in a number and extract each digit
byte countDigits(int num){ byte count=0; while(num){ num=num/10; count++; } return count; }
int getDigit(unsigned int number, int digit) { for (int i=0; i<digit-1; i++) { number /= 10; } return number % 10; }
#define MAX_NUMBER_OF_DIGITS 5 byte array_to_hold_digit[MAX_NUMBER_OF_DIGITS]; void setup(void) { Serial.begin(9600); extractDigit_Save2Arrary(5678); Serial.println(array_to_hold_digit[0]); Serial.println(array_to_hold_digit[1]); Serial.println(array_to_hold_digit[2]); Serial.println(array_to_hold_digit[3]); } void loop(void) { } /*---------------------------------------------------------------------------- count number of digits in a number(integer) ----------------------------------------------------------------------------*/ void extractDigit_Save2Arrary(int number){ byte number_of_digit = countDigits(number); for (byte i=0; i<number_of_digit; i++) { array_to_hold_digit[i] = getDigit(number,number_of_digit-i); //store each digit to array } /* for (byte i=0; i<number_of_digit; i++) { Serial.print(array_to_hold_digit[i]); } Serial.println(); */ } /*---------------------------------------------------------------------------- count number of digits in a number(integer) ----------------------------------------------------------------------------*/ byte countDigits(int number){ byte count=0; while(number){ number=number/10; count++; } return count; } /*---------------------------------------------------------------------------- extract a digit from an number(integer) ----------------------------------------------------------------------------*/ byte getDigit(unsigned int number, int digit) { for (int i=0; i<digit-1; i++) { number /= 10; } return number % 10; }
Debouncing Multiple Switches

- 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.
Arduino function with optional argument(s)
functionReturnType myFunctionName(optionalArgumentType optionalArgument = defaultValue); |
functionReturnType myFunctionName(optionalArgumentType optionalArgument); |
myFunctionName(); // Use the default value |
int myFunction(int optionalArgument = 1); void setup() { Serial.begin(9600); } void loop() { Serial.println(myFunction()); // Use the default value Serial.println(myFunction(2)); // Use specific value } int myFunction(int optionalArgument) { return optionalArgument; }
Arduino running at 8MHz internal clock with Optiboot bootloader
############################################################## |
############################################################## |
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.
- 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
Sharp GP2Y0A21红外线测距传感器

- 距离测量范围:10至80cm(4“到32”)
- 工作电压:4.5V至5.5V
- 输出类型:模拟电压
- 平均功耗:35mA
- 峰值功耗:约200mA
- 允许的最大角度:> 40°
- 更新频率/周期:25 Hz/40毫秒
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
Programming Arduino with an AVRISP MKII programmer

Identify which Arduino bootloader do I have
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 |