Go Down

### Topic: code connections (Read 599 times)previous topic - next topic

#### josh97531

##### Feb 15, 2012, 06:33 pm
i got this code of the internet for one man pong you move the paddle left and right to hit the ball it will hit the wall and come back
it is on a 8x8 LED matrix with a max7219 but which do the clock, load and data pins go to on the arduino

Code: [Select]
`#include <LedControl.h>LedControl myMatrix = LedControl(2, 4, 3, 1);int column = 1, row = random(8)+1;int directionX = 1, directionY = 1;int paddle1 = 5, paddle1Val;int speed = 300;int counter = 0, mult = 10;void setup(){  myMatrix.shutdown(0, false);  myMatrix.setIntensity(0, 8);  myMatrix.clearDisplay(0);  randomSeed(analogRead(0));}void loop(){  paddle1Val = analogRead(paddle1);  paddle1Val = map(paddle1Val, 200, 1024, 1,6);  column += directionX;  row += directionY;  if (column == 6 && directionX == 1 && (paddle1Val == row || paddle1Val+1 == row || paddle1Val+2 == row)) {directionX = -1;}  if (column == 0 && directionX == -1 ) {directionX = 1;}  if (row == 7 && directionY == 1 ) {directionY = -1;}  if (row == 0 && directionY == -1 ) {directionY = 1;}  if (column == 7) { oops();}  myMatrix.clearDisplay(0);  myMatrix.setLed(0, column, row, HIGH);  myMatrix.setLed(0, 7, paddle1Val, HIGH);  myMatrix.setLed(0, 7, paddle1Val+1, HIGH);  myMatrix.setLed(0, 7, paddle1Val+2, HIGH);  if (!(counter % mult)) {speed -= 5; mult * mult;}  delay(speed);  counter++;}void oops() {  for (int x=0; x<3; x++){    myMatrix.clearDisplay(0);    delay(250);    for (int y=0; y<8; y++) {      myMatrix.setRow(0, y, 255);    }    delay(250);  }  counter=0;  speed=300;  column=1;  row = random(8)+1;}`

#### johnwasser

#1
##### Feb 15, 2012, 07:22 pm
Look at LedControl.h to see what order the pins are in.

Here is a similar project: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1244503453

From that it seem like the pins are specified in the order:  Data, Clock, Load.
Send Bitcoin tips to: 1G2qoGwMRXx8az71DVP1E81jShxtbSh5Hp

Go Up

Please enter a valid email to subscribe