View allAll Photos Tagged Compute
Wairarapa REAP tutor Lars (seated at PC) teaches Adult Beginners Computing Class at Eketahuna Library.
Final project for Creative Computing, group project. We created two game controllers and code that works though Arduino to create a soccer/pong type game on the computer. We incorporated sound bytes, LED's and push buttons to acknowledge when some one scores and to move the player across the screen.
Code,
part 1:
int button1 = 0;
int button2 = 0;
int button3 = 0;
int button4 = 0;
int button5 = 0;
int button6 = 0;
int button7 = 0;
int button8 = 0;
int button9 = 0;
int button10 = 0;
// buttons 3-10
int ledPower = 0;
int player1 = 0;
int player2 = 0;
int inByte;
void setup(){
Serial.begin(9600); // begin serial communication
// '9600' speed of our arduino
pinMode(button1, INPUT); //variable name of your button
pinMode(button2, INPUT);
pinMode(button3, INPUT);
pinMode(button4, INPUT);
pinMode(button5, INPUT);
pinMode(button6, INPUT);
pinMode(button7, INPUT);
pinMode(button8, INPUT);
pinMode(button9, INPUT);
pinMode(button10, INPUT);
// buttons 3-10
pinMode(ledPower, OUTPUT);
pinMode(player1, OUTPUT);
pinMode(player2, OUTPUT);
}//END SETUP
void loop(){
if (Serial.available() > 0){ // If data coming from the Serial port is greater than 0,
inByte = Serial.read(); // Then let the variable 'inbyte' hold that data.
//READING SENSOR DATA
button1 = digitalRead(0); //pin on the Arduino
button2 = digitalRead(1); // read button 2
button3 = digitalRead(2); // read button 3
button4 = digitalRead(3); // read button 4
button5 = digitalRead(4); // read button 5
button6 = digitalRead(5); // read button 6
button7 = digitalRead(6); // read button 7
button8 = digitalRead(7); // read button 8
button9 = digitalRead(8); // read button 9
button10 = digitalRead(9); // read button 10
// buttons 3-10
// send sensor values:
Serial.print(button1, DEC); // Sending the data as a whole, human readable number, either 1 or 0.
Serial.print(',', BYTE);
Serial.print(button2, DEC); // Sending the data as a whole, human readable number, either 1 or 0.
Serial.print(',', BYTE);
Serial.print(button3, DEC); // Byte = machine code for a comma, to note separation.
Serial.print(',', BYTE);
Serial.print(button4, DEC);
Serial.print(',', BYTE);
Serial.print(button5, DEC);
Serial.print(',', BYTE);
Serial.print(button6, DEC);
Serial.print(',', BYTE);
Serial.print(button7, DEC);
Serial.print(',', BYTE);
Serial.print(button8, DEC);
Serial.print(',', BYTE);
Serial.print(button9, DEC);
Serial.print(',', BYTE);
Serial.print(button10, DEC);
Serial.print(',', BYTE);
Serial.print('*', BYTE); // Send a '*' to denote the end of the data
}
}
Code,
part 2:
import processing.serial.*; // Open up the Processing Serial Library Instructions
Serial port; // Create a new Serial Port object.
boolean madeContact = false; // A variable to hold see if Processing/computer has connected with the Arduino microcontroller
int RedX = 160;
int RedY = 500;
int BlueX = 1140;
int BlueY = 500;
float x = 650;
float y = 500;
float speedx = -6;
float speedy = 8;
float rx=RedX-3;
float ry=RedY-25;
float rw=6;
float rh=50;
float bw=6;
float bh=50;
float bx=BlueX-3;
float by=BlueY-25;
// variables for buttons
int button1 = 0;
int button2 = 0;
int button3 = 0;
int button4 = 0;
int button5 = 0;
int button6 = 0;
int button7 = 0;
int button8 = 0;
int button9 = 0;
int button10 = 0;
void setup(){
size(1300,1000);
// List all the available serial ports, in array format.
// The fisrt port in the serial list on my macis usually my Arduino module, so I open Serial.list()[0].
println(Serial.list()); // prints out all available ports on your computer
port = new Serial(this, Serial.list()[0], 9600); // Chooses to connect with the first port listed
}
void draw(){
if (!madeContact){ // If I have made contact, 'madeContact' was assigned as 'false',
port.write(65); // Send ASCII code to Arduino asking to send more data.
}
background(0);
field();
playerRed();
playerBlue();
smooth();
noStroke();
fill(255);
ellipse(x,y,20,20);
x = x + speedx;
y = y + speedy;
if (x> 1240 || x 940 || y =465 && y <=538){
fieldB();
noLoop ();
}
}
void keyPressed(){
if(key=='w'|key=='W'){
//fill(255,0,0);
//ellipse (RedX,RedY,50,50);
RedY=RedY-10;
ry=ry-10;
}
if(key=='a'|key=='A'){
//fill(255,0,0);
//ellipse (RedX,RedY,50,50);
RedX=RedX-10;
rx=rx-10;
}
if(key=='s'|key=='S'){
//fill(255,0,0);
//ellipse (RedX,RedY,50,50);
RedY=RedY+10;
ry=ry+10;
}
if(key=='d'|key=='D'){
//fill(255,0,0);
//ellipse (RedX,RedY,50,50);
RedX=RedX+10;
rx=rx+10;
}
if(key=='8'|key=='i'|key=='I'){
//fill(255,0,0);
//ellipse (BlueX,BlueY,50,50);
BlueY=BlueY-10;
by=by-10;
}
if(key=='4'|key=='j'|key=='J'){
//fill(255,0,0);
//ellipse (BlueX,BlueY,50,50);
BlueX=BlueX-10;
bx=bx-10;
}
if(key=='5'|key=='k'|key=='K'){
//fill(255,0,0);
//ellipse (BlueX,BlueY,50,50);
BlueY=BlueY+10;
by=by+10;
}
if(key=='6'|key=='l'|key=='L'){
//fill(255,0,0);
//ellipse (BlueX,BlueY,50,50);
BlueX=BlueX+10;
bx=bx+10;
}
}
void playerBlue(){
strokeWeight(4);
stroke(255);
fill(0,0,255);
ellipse(BlueX,BlueY,50,50);
noStroke();{
fill (255,255,255);
ellipse(BlueX,BlueY,25,25);
rect(bx,by,bw,bh);
}
}
void playerRed(){
strokeWeight(4);
stroke(255);
fill(255,0,0);
ellipse(RedX,RedY,50,50);
noStroke();{
fill (255,255,255);
ellipse(RedX,RedY,25,25);
rect(rx,ry,rw,rh);
}
}
void field(){
background(0,175,30);
smooth();
stroke(255);
strokeWeight(4);
noFill();
ellipse(160,500,180,180);
ellipse(1140,500,180,180); // right side
ellipse(650,500,180,180); //centre
fill(0,175,30);
rect(50,300,165,400);
rect(1085,300,165,400); // rigfht side
fill(255);
ellipse(160,500,10,10);
ellipse(650,500,10,10); //centre
ellipse(1140,500,10,10); // right side
noFill ();
rect(50,50,1200,900);
rect(50,300,165,400);
rect(50,410,55,183);
rect(26,465,24,73);
line(650,50,650,950);
//right side
rect(1195,410,55,183);
rect(1250,465,24,73);
arc(50,50,30,30,0, PI/2);
arc(50,950,30,30,TWO_PI-PI/2, TWO_PI);
arc(1250,950,30,30,PI, TWO_PI-PI/2);
arc(1250,50,30,30,PI/2, PI);
}
void fieldB(){
background(255,13,13);
smooth();
stroke(255);
strokeWeight(4);
noFill();
ellipse(160,500,180,180);
ellipse(1140,500,180,180); // right side
ellipse(650,500,180,180); //centre
fill(255,13,13);
rect(50,300,165,400);
rect(1085,300,165,400); // rigfht side
fill(255);
ellipse(160,500,10,10);
ellipse(650,500,10,10); //centre
ellipse(1140,500,10,10); // right side
noFill ();
rect(50,50,1200,900);
rect(50,300,165,400);
rect(50,410,55,183);
rect(26,465,24,73);
line(650,50,650,950);
//right side
rect(1195,410,55,183);
rect(1250,465,24,73);
arc(50,50,30,30,0, PI/2);
arc(50,950,30,30,TWO_PI-PI/2, TWO_PI);
arc(1250,950,30,30,PI, TWO_PI-PI/2);
arc(1250,50,30,30,PI/2, PI);
}
// -------------------------------------------------- VOID SERIAL EVENT !!
void serialEvent(Serial port){ // Function to read from the Serial Port
madeContact = true; // If Processing has made contact with Arduino, via USB cable
String input = port.readStringUntil('*'); // Read the data string until the bookmarker '*'.
if(input != null){ // If the data string is NOT empty, 'null' . . .
int sensors[] = int(splitTokens(input, ",*")); // Put them into an array called 'sensors' & separate the data by commas
// with the "*' marker at the end to note the end of the incoming data
// The number here changes according to how many INPUT sensors you have connected to the Arduino.
if (sensors.length == 10){ // If the number of sensors is equal to 2
button1 = sensors[0]; // Associate the leftButton to the 1st index of the 'sensor' array.
button2 = sensors[1]; // Associate the rightButton to the 2nd index of the 'sensor' array.
button3 = sensors[2];
button4 = sensors[3];
button5 = sensors[4];
button6 = sensors[5];
button7 = sensors[6];
button8 = sensors[7];
button9 = sensors[8];
button10 = sensors[9];
//button3-10
print("Button1: " + button1 + "\t Button2: " + button2 + "\t Button3: " + button3 + "\t Button4: " + button4 + "\t Button5: " + button5 + "\t Button6: " + button6 + "\t Button7: " + button7 + "\t Button8: " + button8 + "\t Button9: " + button9 + "\t Button10: " + button10); // A print statement for your sensors
println(input);
port.write(65); // Send the ASCII code to request more data,
// To start the process all over again.
}
}
}
The Cloud Computing China Congress (CCCC www.cloudcomputingchina.org/) is specially designed for senior IT and line of business executives evaluating and making purchasing decisions in the areas of on-demand infrastructure and software services.
Hosted in collaboration with Google's CS4HS initiative, the MIT Creative Computing 2012 workshop was held at the MIT Media Lab, August 8-11, 2012.
At The National Museum of Computing www.tnmoc.org at Bletchley Park, on a trip with Sarah, Jenny and Stephen AKA Spacedog.
Some of cloud computing advantages include minimal downtime from waiting on new hardware to arrive, installation, initialized, and finally brought online seems to be a growing trend.
The Cloud Computing China Congress (CCCC www.cloudcomputingchina.org/) is specially designed for senior IT and line of business executives evaluating and making purchasing decisions in the areas of on-demand infrastructure and software services.
Hosted in collaboration with Google's CS4HS initiative, the MIT Creative Computing 2012 workshop was held at the MIT Media Lab, August 8-11, 2012.
Hosted in collaboration with Google's CS4HS initiative, the MIT Creative Computing 2012 workshop was held at the MIT Media Lab, August 8-11, 2012.
Hosted in collaboration with Google's CS4HS initiative, the MIT Creative Computing 2012 workshop was held at the MIT Media Lab, August 8-11, 2012.
Hosted in collaboration with Google's CS4HS initiative, the MIT Creative Computing 2012 workshop was held at the MIT Media Lab, August 8-11, 2012.
Hosted in collaboration with Google's CS4HS initiative, the MIT Creative Computing 2012 workshop was held at the MIT Media Lab, August 8-11, 2012.
On Saturday, July 13, 2013, the Creative Computing Online Workshop facilitation team hosted a one-day symposium at the Harvard Graduate School of Education on the topic of creative computing with Scratch.
cc-symposium.eventbrite.com
scratch-ed.org
Queen's School of Computing undergraduate and graduate students present their work at the annual Creative Computing Showcase.
Hosted in collaboration with Google's CS4HS initiative, the MIT Creative Computing 2012 workshop was held at the MIT Media Lab, August 8-11, 2012.
Hosted in collaboration with Google's CS4HS initiative, the MIT Creative Computing 2012 workshop was held at the MIT Media Lab, August 8-11, 2012.
Hosted in collaboration with Google's CS4HS initiative, the MIT Creative Computing 2012 workshop was held at the MIT Media Lab, August 8-11, 2012.
Queen's School of Computing undergraduate and graduate students present their work at the annual Creative Computing Showcase.
Hosted in collaboration with Google's CS4HS initiative, the MIT Creative Computing 2012 workshop was held at the MIT Media Lab, August 8-11, 2012.