mac online apple blackjack http://www.euro-online.org

DMS 8013: Potentiometer & Graphic

IMG_20160506_202258377

I did this work before the Post-it messages one but I didn’t upload it till now. It is also a piece of work based in serial communication between Arduino and Processing.

Basically Arduino has a potentiometer that send data from it to Processing, which converts the data in a graphic. 

See the result below

- the Potentiometer works well with the software

Click here to view the embedded video.

- the Graphic processing

Click here to view the embedded video.

See below the code:

ARDUINO

void setup() {
// initialize the serial communication:
Serial.begin(9600);
}

void loop() {
// send the value of analog input 0:
Serial.println(analogRead(A0));
Serial.print(analogRead(A1));
// wait a bit for the analog-to-digital converter
// to stabilize after the last reading:
delay(10);
}

PROCESSING
import processing.serial.*;
float xPos = 0; // horizontal position of the graph
float yPos = 0; // vertical position of the graph

Serial myPort;
// change the number below to match your port:
String portName = Serial.list()[2];
void setup () {
size(600,600);
myPort = new Serial(this, portName, 9600);

}

 

void serialEvent (Serial myPort) {
// get the byte:
int inByte = myPort.read();
// print it:
println(inByte);
yPos = height – inByte;
}
void draw () {
background(#024540);
// draw the line in a pretty color:
stroke(#F4D9A7);
line(xPos, height, xPos, yPos);
line(xPos, height, xPos, yPos);
// at the edge of the screen, go back to the beginning:
if (xPos >= width) {
xPos = 0;
// clear the screen by resetting the background:

} else {
// increment the horizontal position for the next reading:
xPos++;
}
}

* Obviously this code is not mine. But if I am honest, I don’t remember the exact source where I took it from as I have been checking many websites, many different codes, I’ve been constantly changing the code, so I think the best thing to do is to post the link I used as a reference:

https://itp.nyu.edu/physcomp/labs/labs-serial-communication/serial-output-from-an-arduino/

https://arduining.com/2013/08/05/arduino-and-processing-graph-example/

 

DMS8013: Post-it on the fridge

kotojelfelesegek

In this post I am going to show one little work I did based on serial communication between Arduino and Processing. As I stated on a previous post, my intention with these series of work was to work on “interaction in the distance”. In this case the interaction is between Arduino and Processing.

The exercise is about changing images in Processing through a pushbutton in Arduino. As I said before,  I am aiming this assessment as a sort practice for my final project.  This final project is going to be two objects (devices) that  communicate to each other and they are meant to be used by people who are in long-distance relationship. So I worked in this exercise thinking that it could be a little screen or display  that one of the member of the couple could put on the fridge (this would be what you see in Processing’s window) and the other guy has a button (the Arduino).  Hence, the idea is to recreate a post-it message’s thread that people who live together usually do when they are not home at the same time.  I am talking about leaving a message to the person you are living with by a post-it on the fridge. As the guys who are in a long-distance relationship can’t leave post-it physically, this a way to do something similar while being in the distance.

Hence, in technical terms, this could be summed up as it follows: the Processing has all the post-it messages that just show up when someone else pressed the button on Arduino.

The first thing I did was to practice the serial communication between Processing and Arduino with a simpler exercise: controlling the LED Pin on Arduino by mousePressed on Processing.

Click here to view the embedded video.

Afterwards, I tried to used the code done by Fabian Winkler, but it didn’t work out, I couldn’t run the sketches. So what did I do? I was thinking “hum if Tom was here he would tell me to break down the whole exercise and start from the beginning. So the first thing to do it’s to check it Arduino is working well”:

1) Checking Arduino: I had to add a LED pin to check if the breadboard was communicating with the laptop. In this checking, I didn’t include the serial communication.

Click here to view the embedded video.

2)Then I added the Serial Communication

Click here to view the embedded video.

So once I made sure that Arduino was working perfectly. I checked the Processing’s sketch.

4) Checking processing: as I way to check if Processing’s sketch was OK was to try to do the same thing that Arduino would do but inside of the Processing’s sketch. What do I mean? Instead of using Arduino to change the images on Processing, I would do it with the mouse with no need of using Arduino. It worked

Click here to view the embedded video.

Then, once I confirmed that both, Arduino and Processing work well independently, I had to try to a serial communication  between them. It does not work though. In the video we can see that there is serial communication coming from Arduino. Whenever I press the button, the number 1 shows up. However, for a reason that I don’t know, it seems that Processing is not receiving the information.

 

Click here to view the embedded video.

But it does, according to this, it is receiving the information from Arduino,  because  at the bottom we can see the number 2 twice, which were sent by Arduino.

So, I still don’t know what the problem can be. I am figuring out as we still have some 2 days left before the deadline. I guess that being sick and with allergies is not a big help

See below the code I’ve used from the source I have mentioned at the top of the post:

ARDUINO

int switchPin = 2;
int LEDPin = 13;
int buttonState = 0;
// the setup routine runs once when you press reset:
void setup() {

// make the pushbutton’s pin an input:
pinMode(switchPin, INPUT);
pinMode(LEDPin,OUTPUT);

// initialize serial communication at 9600 bits per second:
Serial.begin(9600);

}

// the loop routine runs over and over again forever:
void loop() {

// if switch is ON (pressed)
if (digitalRead(switchPin) == HIGH) {
Serial.write(“2″);

digitalWrite(LEDPin, LOW);

}else { //IF switch is OFF (not pressed)
Serial.write(“1″);
digitalWrite(LEDPin,HIGH);

}
delay(100);

}

PROCESSING

import processing.serial.*;

Serial port;
int val = 0;
int oldval = 0;
int numFrames = 4; // The number of frames in the animation
int frame = 0;
PImage[] images = new PImage[numFrames];
void setup() {
size(500, 500);
frameRate(10);
images[0] = loadImage(“0P.jpg”);
images[1] = loadImage(“1P.jpg”);
images[2] = loadImage(“2P.jpg”);
images[3] = loadImage(“3P.jpg”);

 

port = new Serial(this, “/dev/cu.usbmodem1421″, 9600);
}

void draw(){

if (0 < port.available()) {
val = port.read();
}
if (val != oldval && val == 1) {
// the line above makes sure we advance only one frame with
// each pressing of the button
if (frame<numFrames-1) {
frame = (frame+1);
} else {
frame = 0;
}
}
image(images[frame], 0, 0);
oldval = val;
}

 

DMS8013 Digital Media: on the way to the assesment

resized_success-kid-meme-generator-processing-arduino-success-i-win-at-life-1d99ef

After talking to professor Tom, I decided that I am going submit a series of work that have something to do with my final project. As my final project will imply communication with network: from one computer to another, from a smartphone to a laptop… from one device to another device in general. I have not figured them out yet.  Anyway, the final project is about communicating two independent objects that are in the distance. Hence, for this assignment, I should submit 3 possible interactions in the distance.

These series of work could be many different combinations to be honest: communication within local network, communication between Processing and Arduino, communication between two Arduinos…

I have not decided yet which are “those” combinations. I prefer to go step by step, exercise by exercise, otherwise I’ll get overwhelmed with many things that I don’t control very well. Therefore, I have started a piece of work  about a communication between 2 sketches of Processing through OSC (send/receive). My next step will be to try that communication between two computers. Then, play with the kind of messages they could be etc.

Once I have this, I will pass to the next piece of work.

I just hope I  have this feeling once I submit the assignment hahahaha

DMS8013: searching for the series of work to submit

Screen Shot 2016-04-25 at 22.45.35

Click here to view the embedded video.

I have done this in processing, which could be the starting point for one the exercise that I have to submit. My goal is to create more “bouncing balls” that may crash into each other and behave in a determined way when that happens, for e.g. they turn into one that is bigger. It would be kind of that exercise with particles we saw in class before the Easter break. I will also think about small details to add.

DMS8013: Playing around with the Solar System

It has been awhile since I played around the exercise we saw the other day in class, “The Solar System”, in which we learnt “ matrix translations “. I simply forgot to upload the outcome on the blog. When I started working with this exercise, I had at least two goals:

- creating a moon  orbiting the planet Earth.

- adding textures to the 3D spheres in order to make them look what they are representing.

I took me many hours to figure out how to achieve those goals. I didn’t achieve them in the way I was thinking all the time, so I ended up changing the code I was using from the beginning (the one we created in class).

solar_system_textures

Click here to view the embedded video.

See the code I used:

import shapes3d.*;
import shapes3d.animation.*;
import shapes3d.utils.*;

import processing.opengl.*;
Ellipsoid sun, earth, moon, stars;
Box orbiter;

boolean attached = true;

//this is angle, which is equal to 0
float sunRot = 0;
float ang = 0.0;
float angleDirection = 1;
PImage sunmap;
int y;
PImage starfield;

void setup (){
size(1200, 600, OPENGL);
smooth();
hint(ENABLE_DEPTH_SORT);
background(255);
starfield = loadImage(“starfield.jpg”);

// create the sun
sun = new Ellipsoid(this, 16, 16);
sun.setTexture(“sun.jpg”);
sun.setRadius(90);
sun.moveTo(new PVector(0, 0, 0));
sun.strokeWeight(1.0f);
sun.stroke(color(255, 255, 0));

sun.tag = “Sun”;
sun.drawMode(Shape3D.TEXTURE);

// create the earth

earth = new Ellipsoid(this, 15, 15);
earth.setTexture(“earth.jpg”);
earth.drawMode(Shape3D.TEXTURE);
earth.setRadius(30);
earth.moveTo(0, 0, 220);
earth.tag = “Earth”;

// create the moon

moon = new Ellipsoid (this, 20,20);
moon.setTexture(“moon.jpg”);
moon.drawMode(Shape3D.TEXTURE);
moon.setRadius(8);
moon.moveTo(0, -10, -50);
moon.tag = “Moon”;

// Create the star background
stars = new Ellipsoid(this, 10, 10);
stars.setTexture(“starfield.jpg”, 5, 5);
stars.drawMode(Shape3D.TEXTURE);
stars.setRadius(500);
stars.moveTo(0, 0, 0);

// Add the earth to the sun this makes
// its position relative to the sun’s
sun.addShape(earth);
// and the moon to the earth
earth.addShape(moon);
}
void draw () {

//without the ambient light we get very harsh shadows
ambientLight(452, 452, 452);

//SUN
//shift matrix to centre
translate(width/2.0, height/2.0);
pushStyle();

background(0);
pushMatrix();
// Change the rotations before drawing
sun.rotateBy(0, radians(0.6f), 0);
earth.rotateBy(0, radians(0.6f), 0);
stars.rotateBy(0, 0, radians(0.02f));

sun.draw();
stars.draw();
popMatrix();
popStyle();

}

 

 

Playing around with Arduino

After the visit of designer David Chatting, who showedhis project  Family Rituals 2.0.  to us,  I found very interesting the practical use of Arduino in order to link technology with physical objects.

However, As I have never seen an Arduino in my life before this course, I found this learning process tough as well as interesting (challenging). This is like literally ‘learning a new language’. Therefore, I have started playing around with it, and I have done so far one exercise that I found in one of the tutorials that are available on Internet.

Basically, what I did was to put a button, so I could turn off the LED when I pressed the button. Here you can watch the video.

Click here to view the embedded video.

This is the code

 

Code

int ledPin = 13; // choose the pin for the LED

int inPin = 2; // choose the input pin (for a pushbutton)

int val = 0; // variable for reading the pin status

void setup() {

pinMode(ledPin, OUTPUT); // declare LED as output

pinMode(inPin, INPUT); // declare pushbutton as input

}

void loop(){

val = digitalRead(inPin); // read input value

if (val == HIGH) { // check if the input is HIGH (button released)

digitalWrite(ledPin, LOW); // turn LED OFF

} else {

digitalWrite(ledPin, HIGH); // turn LED ON