Go Down

Topic: Playing a game with a photo resistor connected to Arduino (Read 2891 times) previous topic - next topic


Apr 16, 2013, 06:22 pm Last Edit: Apr 16, 2013, 08:44 pm by Metalex Reason: 1
Hi, guys! Here's a simple project, where I use photo resistor to control player's location on the screen. (game coded with Processing)


:) I love this project...

Really good one.

Thanks for sharing.

PD: Just one tip, you can add this. (I see you have to modify the code, according to your light values) Take a look at this, for sure it will be a good addition for your code.


You will see him explaining how to add an "Auto-setup" of the high and low values the photo resistor can read.


I was playing the game, I used a potentiometer to control it.

Just 2 questions. I had to use A0 as an input and not Pin 12.

And another question. Why I lost in the attached file?

Is it possible that a red dot was hiding under the green one, or the code is made to avoid that?

Thanks a lot, I will continue playing :) and trying some changes in the code.


Thanks for your response! It is possible that a red dot was hiding under the green one (it can be fixed by drawing red dots after green ones), because all of them are generated randomly. And I don't think that the input pin matters, as long as it's analog.
I'm glad, that you're having fun checking out this project! Good luck!


Yes, then I realice it was a A12 and not a 12. I have a Nano and 12 was took as Digital Pin 12, and not like in a Mega, Analog 12


Having fun, and not only that, I'm trying to make my version including some .svg graphics to the design :P

But I'm going to start from 0 so I can learn proccesing better.


Cool! You may check out these tutorials on Serial Communication between Arduino and Processing:




Thanks a lot :)

The seconds 2 are new for me, the first one, I already saw it, that guy is a genius, he has a series of over 10 Tutorial about using Arduino, I had learn a lot thanks to those videos :)

Up to now, I'm "smoothing" the AnalogRead to send more stables reading through the Serial. And working in a new code in Proccesing to make a similar game with a few changes :)


This is the small modification I made till now :P

The red dots moves faster, the greens stay at same speed.

The white box is now a "CandyMan"

The next steps would be change the green dots for candies, and the red ones for fruits, as this guy has horrible teeth he prefers the candies :P

I'm playing it with my recently built Joystick (Paddle, kinda like the Atari ones)


Go Up