PONG-TV Mac OS
Contribute to aerickson14/TVPong development by creating an account on GitHub. Pong TV, San Jose, Nueva Ecija. 487 likes 5 talking about this. Wassap sa inyo mga Pabibo. Get up and play some Ping Pong! DDR Game now presents the new and improved interactive game. This game will keep you or your kids off the couch, and will let. The fun original game pong is back and now you can play it.
Introduction: Arduino Pong With TV Output
Here's a simple project that you can do to get acquainted with the TVOut Library, and using an Arduino with RCA Jack outputs! Pong is a classic. The foundations of video gaming start with two lines and a dot bouncing back and forth on a black screen. The Atmega328 is leaps and bounds more powerful than the original pong system (which was either quite a lot of transistors, or a chip with less power than a dollar store calculator), and we'll have no problem making a pong clone with arduino. If you want to make your own game with arduino, this is a cool place to start. Let's make Pong!
Contribute to aerickson14/TVPong development by creating an account on GitHub.
Step 1: Project Parts List:
You can build this with different parts, these are just the suggested ones for simplicity. Don't skip the Sensor Shield, it will save you loads of time, allowing you to skip breadboarding. Our wiring diagram will assume you're using the sensor shield. If you don't want sound, you can skip the Y cable and 2 of the RCA boards.
- 1 x Geekduino or other Arduino UNO / Duemilanove equivalent
- 1 x Sensor Shield for easy wiring
- 1 x RobotGeek Duino Mount
- 1 x RobotGeek Small Workbench
- 1 x RobotGeek Pushbutton
- 2 x RobotGeek Rotation Knob
- 3 x RobotGeek RCA Board
- 1 x Sensor Y Cable
- 1 x 6V Power Supply
- 1 x RCA (Yellow Red and White terminated ends) Cable
- 1 x Huge Ancient CRT Screen Television
- 1 x Childlike sense of wonder
Step 2: Wiring
Follow the diagram to make your TVOut Console. Watch your jumpers, make sure they're set to 5V or you could destroy not only the RCA boards, but the input on your television.
| Device | Sensor Shield Port |
|---|---|
Right Player Control RobotGeek Rotation Knob | Analog 0 |
Left Player Control RobotGeek Rotation Knob | Analog 1 |
Start Button RobotGeek Pushbutton | Digital 2 |
Sync RobotGeek RCA Board 1 | Digital 7 |
Video RobotGeek RCA Board 1 | Digital 9 |
Audio Left Channel (on video pins) RobotGeek RCA Board 2 | Digital 11 |
Audio Right Channel (on video pins) RobotGeek RCA Board 3 | Digital 11 |
Step 3: Programming
Grab the RobotGeek Libraries and Tools from Github, and extract it to your arduino folder.
Open up:
and upload it to your arduino.You're ready to play some pong! This program utilizes the TVout library, which handles drawing shapes, text, and bitmaps to the screen. It is a completely interrupt driven library that will output either NTSC or PAL composite. Pong isn't the only game designed using the TVout library! If you check out Nootropic Design, there are a good handful of games made, and they have a section devoted to helping you design your own! This makes for some great jumping off points on an adventure into making your own video games!
Step 4: Play!
So you might notice that the game isn't particularly challenging. Can you find out where the ball speed is in the code? What would happen if you changed the paddle size? Those sounds are kind of annoying, and there's no music. Could you use the TV.tone function to change that? What about changing the message that appears on screen at game over? Play around with the code and see what you can make happen!
Be the First to Share
Recommendations
Toys & Games Contest
Big vs Small Challenge
Fix It Challenge
Greetings,I am new to Arduino and I thought it would be cool to make Arduino Pong so, I followed this intractable:
and I am getting this error message:
Arduino: 1.6.1 (Mac OS X), Board: 'Arduino Uno'
sketch_mar15a.ino:10:21: fatal error: TVout.h: No such file or directorycompilation terminated.Error compiling.
This report would have more information with'Show verbose output during compilation'enabled in File > Preferences.
If someone could help that would be great!
Thank you,Dave
and I used this code:
/********* Arduino Pong* By Pete Lamonica* modified by duboisvb* A simple implementation of Pong on the Arduino using a TV for output.**/
// #define BUTTON_TWO_PIN 3 //digital to reset and go back to main menu
TVout TV;unsigned char x,y;
boolean button1Status = false;// boolean button2Status = false;
int wheelOnePosition = 0;int wheelTwoPosition = 0;int rightPaddleY = 0;int leftPaddleY = 0;unsigned char ballX = 0;unsigned char ballY = 0;char ballVolX = 2;char ballVolY = 2;
int leftPlayerScore = 0;int rightPlayerScore = 0;
int frame = 0;int state = IN_MENU;
void processInputs() {wheelOnePosition = analogRead(WHEEL_ONE_PIN);// delay(50);wheelTwoPosition = analogRead(WHEEL_TWO_PIN);// delay(50);button1Status = (digitalRead(BUTTON_ONE_PIN) LOW);
// button2Status = (digitalRead(BUTTON_TWO_PIN) LOW);if ((button1Status true)&& (state GAME_OVER)){drawMenu ();}// button1Status = (digitalRead(BUTTON_ONE_PIN));
//cdubois// Serial.println(BUTTON_ONE_PIN);// Serial.println(BUTTON_TWO_PIN);// delay(500);// Serial.println(button1Status);// Serial.println(button2Status);// Serial.println(wheelOnePosition);// Serial.println(wheelTwoPosition);// delay(1000);
}
void drawGameScreen() {// TV.clear_screen();//draw right paddlerightPaddleY = ((wheelOnePosition /8) * (TV.vert_res()-PADDLE_HEIGHT))/ 128;x = RIGHT_PADDLE_X;for(int i=0; i
//draw left paddleleftPaddleY = ((wheelTwoPosition /8) * (TV.vert_res()-PADDLE_HEIGHT))/ 128;x = LEFT_PADDLE_X;for(int i=0; i
//draw scoreTV.print_char(LEFT_SCORE_X,SCORE_Y,'0'+leftPlayerScore);TV.print_char(RIGHT_SCORE_X,SCORE_Y,'0'+rightPlayerScore);
//draw ballTV.set_pixel(ballX, ballY, 2);}
//player LEFT or RIGHTvoid playerScored(byte player) {if(player LEFT) leftPlayerScore++;if(player RIGHT) rightPlayerScore++;
//check for winif(leftPlayerScore PLAY_TO rightPlayerScore PLAY_TO) {state = GAME_OVER;}
ballVolX = -ballVolX;}
void drawBox() {TV.clear_screen();
//draw netfor(int i=1; i

state = IN_GAMEB;}
void drawMenu() {x = 0;y = 0;char volX =3;char volY = 3;TV.clear_screen();TV.select_font(_8X8);TV.print_str(10, 5, 'Arduino Pong');TV.select_font(_5X7);TV.print_str(22, 35, 'Press Button');TV.print_str(30, 45, 'To Start');
delay(1000);while(!button1Status) {processInputs();TV.delay_frame(3);if(x + volX < 1 x + volX > TV.horz_res() - 1) volX = -volX;if(y + volY < 1 y + volY > TV.vert_res() - 1) volY = -volY;if(TV.get_pixel(x + volX, y + volY)) {TV.set_pixel(x + volX, y + volY, 0);
Pong-tv Mac Os X
if(TV.get_pixel(x + volX, y - volY) 0) {volY = -volY;}else if(TV.get_pixel(x - volX, y + volY) 0) {volX = -volX;}else {volX = -volX;volY = -volY;}}TV.set_pixel(x, y, 0);x += volX;y += volY;TV.set_pixel(x, y, 1);}
TV.select_font(_5X7);state = IN_GAMEA;}
void setup() {// Serial.begin(9600);x=0;y=0;TV.start_render(_NTSC); //for devices with only 1k sram(m168) use TV.begin(_NTSC,128,56)
ballX = TV.horz_res() / 2;ballY = TV.vert_res() / 2;
// pinMode(BUTTON_ONE_PIN, INPUT); // sets the digital pin as output}
Pong-tv Mac Os 7
void loop() {processInputs();
if(state IN_MENU) {drawMenu();}if(state IN_GAMEA) {drawBox();}
if(state IN_GAMEB) {if(frame % 3 0) { //every third frameballX += ballVolX;ballY += ballVolY;
// change if hit top or bottomif(ballY <= 1 ballY >= TV.vert_res()-1){ ballVolY = -ballVolY;delay(100);TV.tone( 2000,30 ); }
// test left side for wall hit if(ballVolX < 0 && ballX LEFT_PADDLE_X+PADDLE_WIDTH-1 && ballY >= leftPaddleY && ballY <= leftPaddleY + PADDLE_HEIGHT) {ballVolX = -ballVolX;ballVolY += 2 * ((ballY - leftPaddleY) - (PADDLE_HEIGHT / 2)) / (PADDLE_HEIGHT / 2);delay(100);TV.tone(2000,30 ); }
// test right side for wall hit if(ballVolX > 0 && ballX RIGHT_PADDLE_X && ballY >= rightPaddleY && ballY <= rightPaddleY + PADDLE_HEIGHT) {ballVolX = -ballVolX;ballVolY += 2 * ((ballY - rightPaddleY) - (PADDLE_HEIGHT / 2)) / (PADDLE_HEIGHT / 2);delay(100);TV.tone( 2000,30 ); }
//limit vertical speedif(ballVolY > MAX_Y_VELOCITY) ballVolY = MAX_Y_VELOCITY;if(ballVolY < -MAX_Y_VELOCITY) ballVolY = -MAX_Y_VELOCITY;
// Scoringif(ballX <= 1) {playerScored(RIGHT);// sound delay(100);TV.tone( 500,300 ); }if(ballX >= TV.horz_res() - 1) {playerScored(LEFT);// sound delay(100);TV.tone( 500,300 );}}
// if(button1Status) Serial.println((int)ballVolX);
drawGameScreen();}
if(state GAME_OVER) {drawGameScreen();TV.select_font(_8X8);TV.print_str(29,25,'GAME');TV.print_str(68,25,'OVER');while(!button1Status) {processInputs();delay(50);}TV.select_font(_5X7); //reset the font//reset the scoresleftPlayerScore = 0;rightPlayerScore = 0;state = IN_MENU;}
TV.delay_frame(1);if(++frame 60) frame = 0; //increment and/or reset frame counter}