Arduino MagicDrawBoard Tutorial

Loading...

Sign in or sign up now!
Alert icon
Upgrade to the latest Flash Player for improved playback performance. Upgrade now or more info.
1,189
Loading...
Alert icon
Sign in or sign up now!
Alert icon

Uploaded by on Aug 22, 2009

This is one attempt to recreate the old Magic Draw Board game using the Arduino Board to communicate with Processing through the serial port.
It was based on the patternt.pde bundled with the Processing application.

Hardware you need:
1 Arduino Board
2 Potentiometers
1 Pressure Buttoon
Wires

Software you need:
Arduino Enviroment
Processing Enviroment

Instructions:
Connect the X axis potentiometer to PinAnalog 2, Voltage to 5v and Ground
Connect the Y axis potentiometer to PinAnalog 5, Voltage to 3V and Ground
Connect the Button to PinDigital 0 and Ground

Software:

/*******Use This For Arduino*******/
/**
* SandGameMod.
* Arduino
* DS modded thingy
*
*/
int potPinx = 2;
int valuex = 0;
int potPiny = 5;
int valuey = 0;
int buttonPin = 0;
int val = 0;

void setup() {
pinMode(buttonPin, INPUT);
Serial.begin(9600);
}

void loop() {
valuex = (analogRead(potPinx)); if(valuex(INSERT BIGGER SIGN HERE)0){ Serial.print(valuex); }
Serial.print(","); valuey = (analogRead(potPiny)); if(valuey(INSERT BIGGER SIGN HERE)0){ Serial.print(valuey);
}
Serial.print(",");
val = digitalRead(buttonPin);
if (val == HIGH) { Serial.print("0"); } else {
Serial.print("1");
}
Serial.print(",x");
delay(20);
}
/*******************************/


/*******Use This For Processing*******/
/**
* SandGameMod.
* Processing
* DS modded thingy
*
*/
import processing.serial.*;
Serial myPort;
String myString = null;




float convx;
int conv2x;
int pconvx;
float convy;
int conv2y;
int pconvy;
float convb;
int conv2b;

void setup()
{
size(1024, 680);
myPort = new Serial(this, Serial.list()[1], 9600);
myPort.clear();
myString = myPort.readStringUntil(120);
myString = null;
background(102);
smooth();
}

void draw()
{
pconvx=conv2x;
pconvy=conv2y;
myString = myPort.readStringUntil(120); if (myString != null) { println(myString); String[] stri= split(myString, ',');; println(stri); convx=float (stri[0]); conv2x=int(convx); convy=float (stri[1]); conv2y=int(convy); convb=float (stri[2]); conv2b=int(convb); println(conv2b); if (conv2b==1){ background(random(256),random(256),random(256)); }
}
variableEllipse(conv2x, conv2y, pconvx, pconvy);
variableEllipse2(conv2x, conv2y, pconvx, pconvy);
}

void variableEllipse(int x, int y, int px, int py)
{
float speed = abs(x-px) + abs(y-py);
stroke(speed);
ellipse(x, y, speed, speed);
fill(random(256),random(256),random(256));
}

void variableEllipse2(int x, int y, int px, int py)
{
float speed = abs(x-px) + abs(y-py);
stroke(speed);
ellipse(x, y, speed-10, speed-10);
fill(random(256),random(256),random(256));
}

/*******************************/

Category:

Science & Technology

Tags:

License:

Standard YouTube License

Link to this comment:

Share to:
see all

All Comments (2)

Sign In or Sign Up now to post a comment!
  • cool

  • era um para o jaime, em cor de laranja se faz favor... :)

Loading...

Alert icon
0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more