Electronics Class > Logs for Fall 2009 >
Pong
Thursday, January 7, 2010
The blog has not been updated since the end of break, but we still have been making progress... n stuff. We fit all the LEDs through the plywood board that were strung to wires to make them easier to attach to the breadboard. We also drilled holes on either side of the "screen" to insert the potentiometers as controllers. We used knobs from an old television's volume and channel controls to put on the knobs of the potentiometers to make them easier to twist. Henderson is currently working on attaching the LEDs into the new breadboard, while Ryan and Mike are polishing off the blogs and comments on the programming. We expect to have the wires fully attached and Pong completely working on the new playing board by the end of next week. |
Monday, December 14
Instead of using one-light paddles on either side, we changed the values so that the paddles light up two LEDs at one time n stuff. We also had to change the analog values so that instead of it using pins 0-5, it now uses 0-4 because we used val+1, making it light up the original pin and the next one in succession, and you can't light up pins 5 and 6 when there is no pin 6 n stuff. |
Thursday, December 10th
We're drilling a small plywood board to fit the LEDs through to make a grid instead of the original idea to string them through cut out parts of cardboard. |
Wednesday, December 9
Problems: Make the paddles light up two LEDs at once instead of just one LED. The game is basically unplayable right now because the paddle doesn't allow any room for error - the paddle has to be exactly where the ball lands on your side or you miss it and your opponent gets the point. With two LED's, it increases your chances of deflecting the ball by 100%. While trying to add a second LED to the paddle, Ryan somehow made the paddles completely invisible. Ryan also fixed the sound so that it makes a noise when the ball deflects off of the neutral walls. The paddles are now visible, but still only light up one LED. Henderson did Psychology. Mike wrote this blog. |
Tuesday, December 8
Problems: Make noise when the ball hits the side. Play music for the winning side. Problems Overcome: Make noise when the ball hits the side. Tomorrow's Goal: |
This is our code....n stuff. Jealous?
#include <Tone.h> Tone noiseMaker; int bobb = 0; int score2 =0; int score1 = 0; // sets score as 0 n stuff int player2=0; // player 2 score n stuff int player1=0; // player 1 score n stuff int pace = 1000; // sets pace of ball n stuff int time=0; // sets delay to 0 n stuff int y = 0; // sets initial y value to 0 n stuff int x=0; // sets initial x value to 0 n stuff int xD=1; // int yD=1; // int minus[]={3,4,2,4,2,3,6,7,5,7,5,6,9,10,8,10,8,9,12,13,11,13,11,12,14,15,16,15,16,14}; // declares negatives of pins n stuff int plus[]={4,3,4,2,3,2,7,6,7,5,6,5,10,9,10,8,9,8,13,12,13,11,12,11,15,14,15,16,14,16}; // declares positives of pins n stuff int led; // declares LED n stuff int val =0; // sets inital value to 0 n stuff int val1=0; // int paddleminus1[]= {3,4,2,4,2,3}; // int paddleplus1 []= {4,3,4,2,3,2}; // int paddleminus2[]= {14,15,16,15,16,14}; // int paddleplus2[] = {15,14,15,16,14,16}; // int woot [5][6]= // declares n stuff { {0,1,2,3,4,5}, {6,7,8,9,10,11}, {12,13,14,15,16,17}, {18,19,20,21,22,23}, {24,25,26,27,28,29}, }; // Declares pins in arrays n stuff void setup() // This is the setup n stuff { noiseMaker.begin(17); // makes noise n stuff for (int pin=1; pin<18;pin++) // makes noise at a certain pin n stuff { pinMode(pin,INPUT); // sets pin as input n stuff } Serial.begin(9600); // makes it start n stuff } void loop() // this is the loop n stuff { led=woot[y][x]; // for(time=0;time <= pace;time++) // { val = analogRead(4); // val1 = analogRead(5); // val = map(val,0,1023,0,5); // val1 = map(val1,0,1023,0,5); // pinMode(paddleplus1[val],OUTPUT); // pinMode(paddleminus1[val],OUTPUT); // digitalWrite(paddleplus1[val],HIGH); // digitalWrite(paddleminus1[val],LOW); // pinMode(paddleplus1[val],INPUT); // pinMode(paddleminus1[val],INPUT); // pinMode(paddleplus2[val1],OUTPUT); // pinMode(paddleminus2[val1],OUTPUT); // digitalWrite(paddleplus2[val1],HIGH); // digitalWrite(paddleminus2[val1],LOW); // pinMode(paddleplus2[val1],INPUT); // pinMode(paddleminus2[val1],INPUT); // pinMode(plus[led],OUTPUT); // pinMode(minus[led],OUTPUT); // digitalWrite(plus[led],HIGH); // digitalWrite(minus[led],LOW); // pinMode(plus[led],INPUT); // pinMode(minus[led],INPUT); // } y=y+yD; // sets y = to y plus yD n stuff x=x+xD; // sets x = to x plus xD n stuff if(x>5) // if x value is greater than 5 n stuff {xD=xD*(-1); // x=4; // Sets X value to 4 } if (x<0) // {xD=xD*(-1); // x=1; // Sets X value to 1 } //left side if (y == 0) { if(x==val) { yD=yD*(-1); y=1; pace=pace*.9; // STOPS SOUNDSSSSSSSSSSSSSSSSSSSSSS } else {delay(1000); x=val1; yD=yD*(-1); y= 4; pace=1000; player2= player2+1; for (int bobb=0; bobb<6000;bobb++) for(int score2=0; score2<(player2);score2++) { pinMode(paddleplus2[score2],OUTPUT); pinMode(paddleminus2[score2],OUTPUT); digitalWrite(paddleplus2[score2],HIGH); digitalWrite(paddleminus2[score2],LOW); pinMode(paddleplus2[score2],INPUT); pinMode(paddleminus2[score2],INPUT); delayMicroseconds(10); if (score2==6) { for (int x=0; x<6; x++) { led=woot[y][x]; pinMode(plus[led],OUTPUT); pinMode(minus[led],OUTPUT); digitalWrite(plus[led],HIGH); digitalWrite(minus[led],LOW); delay(500); Serial.println(led); pinMode(plus[led],INPUT); pinMode(minus[led],INPUT); } } } } } //right side if (y == 4) { if(x==val1) { yD=yD*(-1); y=3; pace=pace*.9; noiseMaker.play(400); delay (5); noiseMaker.stop } else {delay(1000); x=val; y=0; pace=1000; player1= player1+1; for (int bob=0; bob<6000;bob++) for(int score1=0; score1<(player1);score1++) { pinMode(paddleplus1[score1],OUTPUT); pinMode(paddleminus1[score1],OUTPUT); digitalWrite(paddleplus1[score1],HIGH); digitalWrite(paddleminus1[score1],LOW); pinMode(paddleplus1[score1],INPUT); pinMode(paddleminus1[score1],INPUT); delayMicroseconds(10); if (score1==6) { for (int x=0; x<6; x++) { led=woot[y][x]; pinMode(plus[led],OUTPUT); pinMode(minus[led],OUTPUT); digitalWrite(plus[led],HIGH); digitalWrite(minus[led],LOW); delay(500); Serial.println(led); pinMode(plus[led],INPUT); pinMode(minus[led],INPUT); } } } } } } |
Group Jobs
Mike- Lord Solder Master Ryan- Head Chief Programmer Alex - White Board/Stupid Mistake Finder smells bad |
1-7 of 7