This is our code....n stuff. Jealous?
Post date: Dec 09, 2009 4:25:33 PM
#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);
}
}
}
}
}
}