Do it yourself with the Cortex-M3 and ADXL345 as a gravity sensing remote control

It’s been a long time since I didn’t write an article. Because there is no time, people say that they are not studying in the senior year. Everyday, like the New Year, I still can’t have that leisure time.

Now almost everyone's hands are an Android smart machine. I am very envious, and I only have a second-hand Nokia N96 that I bought for 380 yuan last semester. Although it is also called a smart machine, it is far from Nowadays, the intelligence of Android is excellent. One of the functions is to play the racing game through gravity induction. I think this is no stranger to everyone. Just tilt the phone and tilt it to control the direction of the car. This function makes the bridge brother envy and hate. Unfortunately, my mobile phone can't be played. Why didn't you make a play last week? Just the last semester began to basically complete the debugging of the substrate of the four-axis aircraft made by the scorpion. The core chip is an M3 microcontroller, a three-axis acceleration sensor ADXL345, and a three-axis digital gyro. To do a simple gravity sensing remote control with M3 combined with ADXL345 can be achieved. In fact, because the previous debugging has written the control function of the chip, and the program of the upper computer has the basis of the program written before the completion of the superintendent, the time spent is rarely two afternoons.

To realize a gravity-sensing remote control system for controlling computer games is also very simple, nothing more than judging the tilt angle of the remote controller at this time, and then M3 will quickly transmit the command to the computer, and the computer gives the same instruction as the direction key of the keyboard according to the command. It’s done. The detection tilt angle is realized by the ADXL345. The three-axis acceleration sensor can measure the acceleration in the xyz direction when it is static. If it is flat, there is only a downward gravity acceleration in the z-axis. If it is tilted, the gravity can be decomposed to xy. The direction, which produces an acceleration in the xy direction, allows you to measure which side of the remote is tilted.

Next, M3 reads the acceleration data of the X-axis measured by the ADXL345 through the IIC bus mode. By judging the data in the X-axis direction, it can be judged which direction the substrate is tilted. Below is the measurement code for M3

After M3 judges the tilt direction, it sends the command to the computer host computer through the serial port of 57600 baud rate. In order to improve the sensitivity and reflection speed of the remote controller, I only use one character here, L stands for left and R stands for right and does not use. Verification does not require the host computer to respond to M3. M3 can only send commands to the host computer continuously, which can greatly improve the efficiency. In actual test, the baud rate guarantees the transmission rate and the bit error rate is also better. low.

After the host computer receives the direction command, it has to simulate the action of our usual keyboard stroke through the code. The program is very simple. It's very similar to the implementation code of the wireless mouse I used to do.

Through this code, you can find that in addition to the left-click command, there is a blank command named 'X', which means that the button is released when the remote is placed horizontally.

The upper computer interface written by VC is as follows

It looks rough and the appearance is not modified. After all, it is electronic rather than software development. As long as it can achieve the functions I need, the software will be ugly. The middle four buttons are used to satisfy some games. You need to press a button all the time. For example, you need to press the arrow keys to go. You can only judge the ADXL345. X-axis data, if combined with the Y-axis data to judge, you can control the up, down, left and right directions at the same time, I will not do this first, because it is still busy recently. The rightmost debug number window is used to monitor serial port data during development, and can also be used for debugging subsequent development of the system.

The measured condition, because the original design of this small board is a miniature four-axis, it is battery-powered, it is very convenient, this battery is also very powerful, I rushed once, I have debugged it for a long time. Still, there is still electricity.

After the remote control is connected to the computer through the serial port, open the software and then open the serial port, then minimize the software and then use it. It has passed a gravity sensor to play the car hidden.

I still use the wired serial port to communicate. If it is a wireless remote control, it will be more perfect. In fact, my board is designed with a 2.4G wireless communication module interface, but writes the data to the wireless module, and then the other side. I have to receive it and then pass it to the computer through the serial port. This adds extra time for a while, which may bring a drop in the sensitivity of the remote control. Of course, I haven’t measured it yet. This is a follow-up development. I have not More time is here, then my focus will be on the quadcopter. Perhaps the best result is that this year's Chinese New Year will allow Otaru to see the four axes that can fly. Of course, it is also possible for him. I can't see it, I can only do my best and have a lot of tasks to do.

2020 hot sale 50w 100w 150w Cob Grow Light, waterproof IP67, use Epistar 50w cob flip chip, pink lighting/3500k white lighting for you to choose.

50w 1pcs cob chip, can replace hps 300w;

100w 2pcs cob chip, can replace hps 500w;

150w 3pcs cob chip, can replace hps 1000w.


Waterproof Best Cob Led Grow Light, is your best choose for indoor plants, each lamp with bracket, easily install.

50w:

Best Cob Led Grow Light

100w:

Diy Cob Led Grow Light

150w:

566565


Grow Light Cob Waterproof

Cob Led Chip,Best Cob Chip,Led Cob Chip Grow Light,Cob Chip On Board Technology

Shenzhen Wenyi Lighting Technology Co., Ltd , https://www.wycngrow.com