Final Project Concept — Morse Code

For my final project, I want to create morse code machine that is controlled by Arduino and is displayed in Processing. I don’t know any Morse code so I would have to spend some time learning the language too. My main purpose of creating this project would be to teach other people how morse code works. Since Morse code is made of dots and dashes, I want to represent those dots and dashes in a more interesting way in Processing. For the Arduino part of the project, I would have buttons that triggers some sound and then have that signal send to Processing. That Processing program would take in the input from the Arduino and draw out the letter the person tapped out.

I might also add a game in the Processing part with letters that pop up. For example, Processing would show the letter A and the player would have to tap out A. This would continue until the game is over or whenever the player chooses to finish.

What I would need:

  1. Momentary Switch Buttons
  2. Piezo Buzzer
  3. Acrylic panel for holding the buttons — laser cutter
  4. LED lights — for emphasize on whether it’s a dot or dash

I’m trying to keep the Arduino part simple so that I could focus more on how I’m going to represent Morse Code in a creative manner. There would be two parts to choose from

  1. Learning Morse code
  2. Playing a Morse code game to test how good you are

Week 11: Physical Controller, Computing Response

Write on this blog a paragraph or two about what computing means to you at this point. Is it adding something to your life? Is it helping you become a better person? What are you getting out of it, what do others get from it?

I’ve never really worked with circuits before and have only played with the basics of it from my electronics class back in high school. I learned about parallel/series circuits and all the semantics/calculations but never put it into practice until this class. From everything we’ve learned from Arduino and Processing, I think I’ve grasped enough basics to create (almost) anything I want. I loved that we’ve learned how to connect software and hardware into one and I’m excited to make my own electronics to better my life. It’s a nice change from just making software/websites to making physical devices. Now that I’ve taken this class, I feel more confident with building actual products. Mark Zuckerberg recently posted about how he made his wife a device that emits a faint night between certain hours for a few minutes at night. If I hadn’t taken this class, I might think this project is very complicated, but I no longer think so.

  • For the project, I created a controller for my game from two weeks ago. My controller moves the bar in the game left to right. For this, I used a potentiometer because it seemed intuitive. If the player loses, the red light goes off and if they win, the green light goes off.
void loop() {
  xPos = analogRead(A0);
  delay(0);
  Serial.write(xPos/4);
  int winInt = Serial.parseInt();
  int loseInt = Serial.parseInt();
  if (winInt) {
    digitalWrite(won, 1);
  }
  if (loseInt) {
    digitalWrite(lost, 1);
  }
}
void serialEvent(Serial port) {
  xPos = map(port.read(), 0, 255, 640, 0);
  port.write(int(won) + "," + int(lost) + "\n");
}

Connecting Arduino to Processing

For this week’s exercise, I have decided to connect arduino to one of my previous exercise – the recreation on Computer Graphics & Art. The structure of the code is similar to the previous exercise, but I have added conditional statements on each if-statements that draws the strokes based on the location. For the physical part on the Arduino, I have mapped the value of the potentiometer into the integer range from 0 to 8, where each integer serves as an opening indicator for each layer. When the mapped value is at 0, none of the strokes are initiated but as you increment the value using the potentiometer, the layers show the strokes – and the general flow of the layers starts from the center as the initial layer and expands to the outer layers.

The video below is a short demo of the exercise:

<Source Code – Arduino>

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  Serial.println('0');
}

void loop() {
  if(Serial.available()>0){
    char inByte=Serial.read();
    int sensor = analogRead(A0);
    delay(0);
    Serial.println(sensor);
  }
}

<Source Code – Processing>

int w = 40;
int h = 40;
IntList indexes;
ArrayList<int[]> coords;

import processing.serial.*;
Serial myPort;
int trigger = 0;

void setup() {
  size(680, 680);
  
  printArray(Serial.list());
  String portname=Serial.list()[2];
  println(portname);
  myPort = new Serial(this,portname,9600);
  myPort.clear();
  myPort.bufferUntil('\n');
  
  rectMode(CENTER);
  coords = new ArrayList<int[]>();
  indexes = new IntList();
  
  for (int i = 0; i < 8; i++) {
    indexes.append(i);
  }
  
  indexes.shuffle();
  
  int[] coords1 = {-15, 0, 15, 0};
  int[] coords2 = {-15, 0, 0, -15};
  int[] coords3 = {-15, 0, 0, 15};
  int[] coords4 = {-15, -15, 15, 15};
  int[] coords5 = {0, -15, 0, 15};
  int[] coords6 = {0, -15, 15, 0};
  int[] coords7 = {0, 15, 15, 0};
  int[] coords8 = {15, -15, -15, 15};
  
  coords.add(coords1);
  coords.add(coords2);
  coords.add(coords3);
  coords.add(coords4);
  coords.add(coords5);
  coords.add(coords6);
  coords.add(coords7);
  coords.add(coords8);
}

void draw() {
  strokeWeight(3);
  background(255);
  for (int i=0; i < height; i += h) {
    noFill();
    for (int j=0; j < width; j += w) {  
      noFill();
      pushMatrix();
        translate(i+w/2, j+h/2);
        for(int k = 0; k < 7; k++) {
          noFill();
          if (i+w/2 < 40 || j+h/2 < 40 || i+w/2 > 640 || j+h/2 > 640) {
            if (trigger > 7) {
              fill(255, 240, 240);
              line(-15, 0, 15, 0);
              line(-15, 0, 0, -15);
              line(-15, 0, 0, 15);
              line(-15, -15, 15, 15);
              line(0, -15, 0, 15);
              line(0, -15, 15, 0);
              line(0, 15, 15, 0);
              line(15, -15, -15, 15);
            }
            if (k == 0) {
              rect(0, 0, 30, 30);
            }
          }
          else if (i+w/2 < 80 || j+h/2 < 80 || i+w/2 > 600 || j+h/2 > 600){
            if (trigger >= 7) {
              fill(255, 210, 210);
              int coordArr[] = coords.get(indexes.get(k));
              line(coordArr[0], coordArr[1], coordArr[2], coordArr[3]);
            }
            if (k == 0) {
              rect(0, 0, 30, 30);
            }
          }
          else if (i+w/2 < 120 || j+h/2 < 120 || i+w/2 > 560 || j+h/2 > 560){
            if (k < 6 && trigger >= 6) {
              fill(255, 180, 180);
              int coordArr[] = coords.get(indexes.get(k));
              line(coordArr[0], coordArr[1], coordArr[2], coordArr[3]);
            }
            if (k == 0) {
              rect(0, 0, 30, 30);
            }
          }
          else if (i+w/2 < 160 || j+h/2 < 160 || i+w/2 > 520 || j+h/2 > 520){
            if (k < 5  && trigger >= 5) {
              fill(255, 150, 150);
              int coordArr[] = coords.get(indexes.get(k));
              line(coordArr[0], coordArr[1], coordArr[2], coordArr[3]);
            }
            if (k == 0) {
              rect(0, 0, 30, 30);
            }
          }
          else if (i+w/2 < 200 || j+h/2 < 200 || i+w/2 > 480 || j+h/2 > 480){
            if (k < 4 && trigger >= 4) {
              fill(255, 120, 120);
              int coordArr[] = coords.get(indexes.get(k));
              line(coordArr[0], coordArr[1], coordArr[2], coordArr[3]);
            }
            if (k == 0) {
              rect(0, 0, 30, 30);
            }
          }
          else if (i+w/2 < 240 || j+h/2 < 240 || i+w/2 > 440 || j+h/2 > 440){
            if (k < 3 && trigger >= 3) {
              fill(255, 90, 90);
              int coordArr[] = coords.get(indexes.get(k));
              line(coordArr[0], coordArr[1], coordArr[2], coordArr[3]);
            }
            if (k == 0) {
              rect(0, 0, 30, 30);
            }
          }
          else if (i+w/2 < 280 || j+h/2 < 280 || i+w/2 > 400 || j+h/2 > 400){
            if (k < 2 && trigger >= 2) {
              fill(255, 60, 60);
              int coordArr[] = coords.get(indexes.get(k));
              line(coordArr[0], coordArr[1], coordArr[2], coordArr[3]);
            }
            if (k == 0) {
              rect(0, 0, 30, 30);
            }
          }
          else if (i+w/2 < 320 || j+h/2 < 320 || i+w/2 > 360 || j+h/2 > 360){
            if (k == 0) {
              rect(0, 0, 30, 30);
            }
            if (k < 1 && trigger >= 1) {
              fill(255, 30, 30);
              rect(0, 0, 30, 30);
              int coordArr[] = coords.get(indexes.get(k));
              line(coordArr[0], coordArr[1], coordArr[2], coordArr[3]);
            }
          }
          else
          {
            fill(255, 0, 0);
            rect(0, 0, 30, 30);
          }
        }
      indexes.shuffle();
      popMatrix();
    }
  }
  delay(50);
}

void serialEvent(Serial myPort){
  String s=myPort.readStringUntil('\n');
  s=trim(s);
  if (s!=null){
    trigger=(int)map(int(s),0,1023,0, 8);
  }
  println(trigger);
  myPort.write('0');
}

 

Physical Computing – harder than it seems… or maybe not so much so

 

Physical computing means building interactive physical systems by the use of software and hardware that can sense and respond to the analog world. – wikipedia

This is the Wikipedia definition of physical computing, but it is a very general, very vague one. Starting this course, I had a general idea on what we might be doing, but I never really expected to connect so much with “emotion” and with “being”. My previous notion of interactive art consisted of the following: “Make something move with code and wire”. The layers were not quite clear and it was a sort of “black box”. Now that we are almost at the end of the semester, with so much basic knowledge about physical computing, I can finally see all the layers that might be there in, say, for example, an interactive installation.

Is it helping me become a better person? I don’t know if it’s helping me become a better person, but it’s helping me evolve into a different type of artist. When I think about what type of projects I want to do in the future, I no longer think exclusively of paintings and “archivable” art. I think of interactive installations I want to build and causes I want to help with these installations.

Is it adding something to my life? Yes, it is adding skills to my list of “things I can pull off under extreme stress, pressure, and approaching deadlines”. It is giving me an extension, or rather a whole other creative outlet. While coding is never going to make me as emotional as painting does, it is a big part of interactive art and helps bring things to life.

 What are am I getting out of it? Currently, I would say the satisfaction of getting this course over with and (hopefully) passing. In the future perhaps a job, and maybe a medium through with I can make a change in the world, regardless of how small it may be. All big change starts with small attempts towards a larger goal.

What do others get from it? The experience. Everyone has their own interpretations of a piece. Which is what makes physical computing so special. It takes people beyond just the visuality of the project. You can touch it (not in all cases of course). In other words, you get to be “one with the piece”.

Serial Communication: A Joystick to my OOP Game

For this week’s assignment I built upon the assignment I created two weeks ago for the Object Oriented Programming game. I added a joystick to control the square’s movement, as well as a potentiometer so the user can choose a color for the square throughout the game.

It was challenging to figure out how to send the information from the Arduino to Processing, but I am a lot more confident now in understanding how the Arduino sends information to Processing and how Processing uses this information.

The user uses the potentiometer attached to a breadboard, while they can use the joystick to control the customized square’s movement.

Here is a video of the joystick and potentiometer in action:

Below is the code for the Processing sketch:

import processing.serial.*;
Serial myPort;
int xPos, yPos;
int xMove;
int bgValue;

float monsterSpotY = random(300, 560);
float monsterSpotX = random(200, 560);
float monsterRadius = 40;
int gravity = 1;
int coloramt = 0;

class Player { 
  float x;
  float y;
  float up;
  float down;
  float left;
  float right;
  float speed;
  float maxJump;
  float side;
  float prevY;
  Player() {
    x = 0;
    y = 580;
    up = 0;
    down = 0;
    left = 0;
    right = 0; 
    speed = 4;
    maxJump = 400;
    side = 20;
    prevY = 1;
  }    
  void display() {
    fill(255, 100, finalbgValue);
    rect(x, y, side, side);
  }    
  void update() {
    x = x + (xPos) * speed;
    if (prevY == 1) {
      gravity = 1;
      y = y + (yPos + gravity) * speed;
    }
    //prevY = y;
    println(prevY);
    println("ypos is " + yPos);
    if (x <= 10) {
      if (y >= height - 10) {
        x = 10;
        y = height - 10;
      } 
      else if (y < height - 10) {
        x = 10;
      }  
    } else if (x >= 590) { 
       if (y >= height - 10) {
        x = 590;
        y = height - 10;
       } else if (y < height - 10) {
        x = 590;
      }   
      } 
     else if  (y <= 0) {
      y = 0;
    } else if (y >= 590) {
      y = 590;
      prevY = 1;
    } 
    if (y <= 480) {
      prevY = 2;
    }  
    if (prevY == 2) {
      gravity = 3;
      y = y + (yPos + gravity) * speed;
    }   
  }
} 
class Monster {
  float x;
  float y;
  float radius;
  float ySpeed;  
  float monsterSpotY;
  float monsterSpotX; 
  color monsterColor;
  Monster() {

    radius = monsterRadius;
    ySpeed = random(2, 6);
    monsterSpotX = random(0, width);
    monsterSpotY = random(0, 100);
  }    
  void show() {
    //monsterColor = color(map(monsterSpotY, 0, height, 0, 255), map(monsterSpotY, 0, height, 100, 150), map(monsterSpotY, 0, height, 150, 255));      

    fill(coloramt);
    noStroke();
    ellipse(monsterSpotX, monsterSpotY, monsterRadius, monsterRadius);
  }
  void fall() {
    monsterSpotY = monsterSpotY + ySpeed;
    if (monsterSpotY > height) {
      monsterSpotY = random(-200, 300);
      monsterSpotX = random(0, width);
    }
  }
  void run() {
    fall();
    show();
  }
}
int counter = 0;
int gameState = 0;
int finalbgValue;
Player myPlayer;
Monster myMonsters[];
void setup() {
  size(600, 600);
  myPlayer = new Player();
  int monsterCount = 100;
  myMonsters = new Monster[monsterCount];
  for (int i = 0; i < monsterCount; i++) {
    myMonsters[i] = new Monster();
  }
  printArray(Serial.list());  
  String portname=Serial.list()[69];
  println(portname);
  myPort = new Serial(this, portname, 9600);

  //myPort.bufferUntil('\n');
}    

void draw() {
  background(255);
  
  // configuration state; user can select color. 
  if (gameState == 0) {
    textAlign(CENTER);
    fill(0);
    text("Color your hero!", width / 2, 200);
    fill(255, 100, bgValue);
    rectMode(CENTER);
    stroke(0);
    rect(width / 2, 290, 120, 120);
    fill(100);
    rect(width / 2, 395, 140, 30);
    fill(0);
    text("Click here to play!", width / 2, 400);
    println(mouseX);
    println(mouseY);
    if (mousePressed == true && mouseX > 230 && mouseX < 370 && mouseY > 383 && mouseY < 414) {
      gameState = 1;
      finalbgValue = bgValue;
    }
  } else if (gameState == 1) {
    myPlayer.display();
    myPlayer.update();    
    gameOver();
    fill(0);
    text(counter, width - 40, 30);
    int counterIncrement = counter /7;
    for (int i = 0; i < counterIncrement / 20; i+= 1) {
      myMonsters[i].run();
      if (i == counterIncrement / 20) {
        i = 0; 
        println(i);
      }
    }  
    counter++;
  } else if (gameState == 2) {
    textAlign(CENTER);
    background(255);
    text("You Died! Your score is: " + counter, width/2, height / 2);
    text("Click here to play again", width / 2, height / 2 + 30);
    if (mousePressed == true && mouseX > 230 && mouseX < 360 && mouseY > 320 && mouseY < 340) {
      gameState = 1;
      counter = 0;
      myPort.stop(); 
      // ^ myport clears serial before running setup again
      setup();
    }
  }
}  


void serialEvent(Serial myPort) {
  String temp=myPort.readStringUntil('\n');
  temp=trim(temp);
  if (temp != null) {
    int values[]=int(split(temp, ','));
    //split string of inputs by commas and end at line break "/n"
    if (values.length == 3) {
      xPos=(int)(values[0]);
      yPos=(int)(values[1]);
      bgValue = (int)(values[2]);
      xPos =(int) map(xPos, 0, 1023, -3, 3);
      yPos =(int) map(yPos, 0, 765, 3, -3);
      bgValue = (int) map(bgValue, 0, 1023, 0, 255);
    }
  }
}

void gameOver() {
  for (int i = 0; i < 30; i++) {
    if (myPlayer.x + 20  > myMonsters[i].monsterSpotX - 20 && myPlayer.x - 20 < myMonsters[i].monsterSpotX && myPlayer.y - 20 < myMonsters[i].monsterSpotY && myPlayer.y + 20 > myMonsters[i].monsterSpotY - 10) {
      gameState = 2;
    } else {
    }
  }
}

Below is the code for the Arduino:

void setup()
{
  Serial.begin(9600); 
  pinMode(4, INPUT); 
  pinMode(A1, INPUT);
  pinMode(A2, INPUT);
  pinMode(A0, INPUT);

}

void loop() {
  int xValue = analogRead(A1);
  int yValue = analogRead(A2);
  int sensor = analogRead(A0);
   
  Serial.print(xValue);
  Serial.print(",");
  Serial.print(yValue);
  Serial.print(",");
  Serial.println(sensor);
}

 

What Computing Means to Me

I think that computing has become a very important part of my life because it has opened up many ways for me to express myself and create. I find it fascinating how computers are able to do pretty much anything we want as long as we are able to code it and provide it all the information necessary. This is still one of the most frustrating yet rewarding parts of computing for me: learning how to code. It can be so tantalizing yet exciting when I want to create something I conceived and I really have to understand why the program is doing this and not doing that. I will always feel like there is something that I can improve upon for all my projects, more techniques I can learn and more creative barriers to tackle using my skills in computing.
But what excites me the most is computing’s potential. Computers have clearly changed the world dramatically over the past few decades, and I often think about how this impacts the way people think and the way we function. I have mixed feelings about computers and their effects on society and this is a big reason as to why I am so drawn to interactive media and computing. I am especially excited to see how computing will change the world in the future, and am thrilled to be a part of this process and gaining the skills necessary to perhaps shape it. In summary, computing means a lot to me: it means power, it means frustration, it means being precise, it evokes feelings of dread in me when thinking about the future, apprehension, while also making me feel happy, playful and in awe of how convenient life can be in the age of computers. The usefulness of computing in my personal life and as a potential career, combined with how important it will be for humanity’s future make it one of the most interesting things that I have ever had the opportunity to explore. 

What does computing mean to me?

At this point, computing, or coding in particular, to me means a new way of thinking. I’m pretty sure that many people can relate to the story of coming from a rather outdated educational system to a new one, which actually cares about what you think and how you think. Though for me this transition from memorizing as a way of learning to critical thinking was introduced after entering the IB, after coming to NYUAD, it only deepened.

In particular, taking Intro to IM (and coding for the first time) challenged the way I look and solve problems a lot. Trying to come up with efficient ways (instead of time-consumingly ‘hardcoding’ the whole thing) that can be then very easily changed and applied to something else too, as well as bottom-down approach and breaking things down to smallest possible components gave me a lot of trouble at first, but at the same time gave me a good foundation of new valuable cross-disciplinary  skills.

Especially in relation to my love for (graphic) design, questioning the way I build things that people later interact with reshaped the way I think when designing. I started trying to predict what the reaction of the person will be and taking this prediction to my advantage when design decisions are to be made. This is where most of the readings came in handy – as the theoretical basis of design is often underdeveloped and underestimated, I never really put that much effort into exploring design through written pieces that raise critical questions and put things we take for granted into perspective.

Overall, calling the experience with computing becoming a better person would a bit of a stretch, but calling it becoming a person who is more critical and practical in regards to problem-solving and designing captures it a little better.

Final Project Brainstorm

For my final project, I wanted to do a sort of continuation of my midterm project (the Sunflower); however, this time I would have used a real plant with a moisture sensor and other data sensors that I could then analyze on a screen using processing (AKA to know when to water the plant etc.). However, I didn’t think this involved much interaction (or the interaction was just too long term).

So then, I thought about creating an interactive game, a form of Dance Dance Revolution but for the hand. Again, I liked this concept a lot because the interaction is more clear but it lacked creativity.

So I’m considering combining the two and creating a game where the player has to move the plant on screen (using tangible buttons) and collect water droplets. Hopefully, as they collect more water, the more the plant grows. I’m not yet sure I want to do this 100% though. For this, I would need my Arduino, buttons (arrows), wiring and a box of some sort. The rest would be coded into Processing/Arduino directly.

Computing

I initially took IM for 2 reasons; to get a bit familiar with coding incase I need to adjust parts of my website, and because all my IM major friends told me I’d enjoy it, which I did. But having looked at and understood how such interesting things can and are made with coding has been really interesting and thought provoking for me. From the games that I used to think only professionals could make, to mind blowing interactive art.

In high school I took a course that taught us about the impact of computing on the world, from RFID to the Internet and security. But in this course I learnt to actually make things and work with computing, and actually do something. Coding is still very challenging for me to wrap my head around, but I no longer see it as a foreign skill that only certain people can do.

Throughout my childhood, whenever I was asked what I wanted to become, my only answer was “An inventor”. Not a doctor or lawyer or even an artist. Inventor. I was told that is not a job and so I sort of slowly let it go. I still remember when we got our IM kits, and I saw it said “Inventor’s kit”. It felt like destiny.

I still feel a bit intimidated by coding and computing but I definitely feel  it has given me much more room for exploration.

Final Project Idea

For my final project, I hope to create an interactive installation that combines both light and sound that uses analog input that influences both LED and a generative art piece created using Processing.

Here is a rough sketch of the project.

I realize that it is hard to see these sketches, but essentially I plan to have one large projection of a Processing sketch, and in front of that, six beams that hold LEDs, and finally a control panel for the user.

The Processing sketch will be able to be controlled by the user through a large touch sensor, or a series of touch sensors, and effects will happen in the corresponding spot on the sketch that the user touches on the touch pad. I am still not sure how to do this, or if this is even possible to do considering that I want the correspondence to be very precise.  I am in the process of looking at pieces of generative, interactive art created using Processing that I might be able to gain inspiration from.

Secondly, I will create a second control panel with six touch sensors that will correspond to each of the LED beams hanging in front of the user. These will be clear acrylic beams with three RGB LEDs inside. When there is no touch or force detected, the LEDs will remain at a certain brightness. When a touch is detected, the LED will light up exactly how strong the force the user puts into the sensor. Each LED will have exactly one color that the user is able to manipulate. A touch of the sensors will also result in a corresponding sound being played aloud.  The beams will also appear to “wrap around the user,” with the closest beams being directly to the right and left of the user.

The Processing sketch will also have a sound being played, probably a more bass-like, ambience noise, while the beams and their sensors will produce sounds that correspond to musical notes.  This will allow the user to be immersed in a sound and light piece that they are able to see direct feedback from.

As of now, I believe that these are the parts I require:

  • 18 RGB LEDs
  • 6 panels of transparent acrylic
  • 6 sound amplifiers
  • 6 force/touch sensors (small)
  • 1 large touch sensor with the ability to detect where the touch occurred (I do not know if this is possible)
  • 1 projector