8 years, 5 months ago.

coding suggestions?

I am using the mbed starter kit from sparkfun electronics. i am attempting to use the accelerometer, lcd screen and a buzzer to make an interactive maze on the screen, where when you hit a wall with a ball controlled by the accelerometer the buzzer sounds. Any tips on how write the code to make the buzzer sounds when the ball hits the wall.

1 Answer

8 years, 5 months ago.

You need some what of your program checking if the ball has hit a wall on the screen, If you have a way of checking the colour of a specific pixel on the display then the simplest method is to calculate where you want to draw the ball and then check the pixel at that location, if it's the colour for a wall then you've hit something.

If you can't check screen pixels then you can have a 2D char array that is the same size as your display resolution, fill it with 0 for no wall or 1 for wall and then check the correct location in that. This will be faster but will eat up more memory (1 bytes per pixel).

There are other more memory efficient ways to do things but they get more complicated.