Help with Ping Pong Game using Arduino + Accelerometer

Submitted by Zerseus on Wed, 09/27/2017 - 01:37

Re: B.Ashwinth Raj's reply on this page: https://circuitdigest.com/microcontroller-projects/ping-pong-game-using…

As I mentioned in my comment, I haven't changed much of the Processing code, this is the only major change that I've made that caused the data to be read: https://image.prntscr.com/image/oOD49Zm_Sze1W-0AqRmt2A.png

Here's a pastebin of the code if you need: https://pastebin.com/yPxHfDkB

Anyway, the main problem (as I mentioned in my comment) is that the accelfilter isn't connecting to the Processing code for some reason.

I've tried the serial monitor and the Processing console thing several times before, and as I said, the serial monitor values are smooth (https://image.prntscr.com/image/uLdZKQQ2TECqraBbMOGoUQ.png) whereas the Processing console contains a lot of noise/non-smooth values (https://image.prntscr.com/image/giCWpSOsT3qiWRQSbp8-vg.png), which in turn causes the bar to vibrate in-game rather than move smoothly.

Any suggestions on how to fix this? Any help would be appreciated!

Hi Zerseus,

Actually you are getting a smooth output on your processing IDE also. It is just that you did not understand it, because of the ASCII convertion involved.

In this pircture https://image.prntscr.com/image/uLdZKQQ2TECqraBbMOGoUQ.png taken from Arduino Serial monitor the values are

M77

M77

.....

If you map them and convert them to ascii you will get

M77 = 406 453 453 (548)

Here the letter M is represented using 406, 7 is represented using 453 and the neline is represented using 548.

 

I know this might confuse you a bit because of the mapping involved in the project. To understand what is happenign write a simple arduino program to write some data through serial monitor and read it using a the processing sketch and display the value on its console, have a ASCII chart with you for reference and you will understand how the data is converted and read.  

Sorry for the late reply, hope this helps you.

 

  Joined August 16, 2016      998
Tuesday at 12:29 AM

I see, so the smooth output of the Accelfilter is as an ASCII value? So it isn't the problem of reading the serial data? Then why does the bar keep jittering/vibrating instead of moving smoothly? I assumed it was because the values being sent weren't constant. I would greatly appreciate it if you could help me with this.

I was also wondering if you could explain what "toSend = map (smoothData1, 213, 607, 0, 255);" and "movby = int(map(float(data), 255,0,0,100));" do. Are they connected in some way? Do the 4 values need to be the same?

Sorry for the trouble, I'm a complete beginner at this.

  Joined September 27, 2017      1
Wednesday at 12:12 AM