Final Project: Report

Project Title: Red light, Green light Race

Student: Rebecca Xiong

Instructor: Rodolfo Cossovich

Conception and Design:

The idea for my project comes from my daily life. When I go for lunch with my friends, one of them always runs a red light and has his eyes fixed on his phone. We are so worried that he might be knocked by passing cars, though he never worries about that. What’s more, I enjoyed the game “red light, green light” when I was a child. The game includes many players, one child stands far away from others and counts down, while other children try to run as quickly as possible towards that child when the child mentions the light is “green”. At the beginning, I wanted audience to interact by pressing buttons. With the research I had done  and the suggestions from my instructor, I decided to add more body engagement to this project to make audience more engaged. During the user testing, the sensors stopped working, so I had to find another way to plug the sensors. The screen after the game ended was messed up because I used the wrong code. After the user testing, I lowered the sensitivity of the sensors and modified the requirements for gaining points, and found another code to stop the game when a player winned by getting enough points or a player lost by breaking the rules. The modifications are somehow successful, but the players need to step really hard to get a point after that.

Fabrication and Production:

My project consists of three parts: sensors, code and decorations.

I tried the vibration sensors borrowed from equipment room at first, but the output varied too greatly and the wires fell out easily, so I bought another kind of vibration sensor from Taobao. The result was really ideal when I did experiment on 15th floor that I just need to stick the sensor to a plastic mat and nice carpets under it, however, there were no carpet on 8th floor so the sensor could not detect the vibration, and the output of these sensors were not stable, so I had to buy a couple of more sensors to make sure some of them could work well.

The goal of the code is that when the players are stamping on the mat, the vibration should be recorded and the players should get points when they stamp. When the red light is on, the players should stop immediately, or they may lose the game. It should be able to record the values of the sensors, add them up, decide who can win and play videos to make the players more engaged. The videos of two people running across the street is made by myself on iPad with an app called PaperClip. 

I made a traffic light with an LED matrix and a piece of wood cut by lazer. I painted it black to make it look like a real traffic light. I found a mobile phone holder at home to hold the light. The color of the light is exactly the same as what color is shown in Processing. The traffic light is made to make my project more attractive to the audience who are not interacting with the project right now. I used grey plastic mats and sticked white pieces of cardboard onto them to simulate the real zebra crossing, and put sensors under the cardboards, so they could detect the change in pressure when the players stepped on the cardboards. These decorations make my project more vivid and attractive, and make the players feel as though they were really running across a street. I think this design improves the interacting experience to a great extent.

Conclusions:

The goals of my project is to tell the audience the important of following the traffic rules and to help them recall their childhood memories of playing games with their friends, while providing an exciting, competitive, physically-engaging interaction experience. My project has achieved its stated goals very well according to the feedback I got from the user test and presentation. The players become more and more engaged as the game is played, so it aligns with my definition of interaction that when there are outcomes, the audience become willing to give more incomes. I would add some audio support to the game if I had more time. I want to add the voice of the traffic police wistling when the redlight turns on, and voices of celebration when a player wins, to make the game experience more immersive. I learn to detect the errors from different perspectives when I could not run the sketch (it really happened a lot when I was working on the project). I also learned that I should think about how to make the project better no matter which step I am in, because it is never too late for me to improve my project. I am satisfied with my project, because it is engaging, attractive, complete, meaningful, and most improtantly, interactive.

Annex:

Code for arduino:

#include "SerialRecord.h"
#include <FastLED.h>

#define NUM_LEDS 256  
#define DATA_PIN 3    
CRGB leds[NUM_LEDS];

SerialRecord writer(2);
SerialRecord reader(1);
void setup() {
  Serial.begin(9600);
  FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);  
  FastLED.setBrightness(10);
}

void loop() {
  reader.read();
  int sensorValue1 = analogRead(A0);
  int sensorValue2 = analogRead(A1);

  if (sensorValue1<=45){
  writer[0] = 0;
  }
  if (sensorValue1>45){
  writer[0] =1;
  }
  if (sensorValue2<=25){
  writer[1] = 0;
  }
  if (sensorValue2> 25){
    writer[1] =1;
  }
  int light = reader[0];
  writer.send();

  delay(100);
  if (light == 1){
 
    for (int x = 81; x <= 256; x = x + 1) {
    leds[x] = CRGB(0, 0, 0);}
    for (int x = 0; x <= 80; x = x + 1) {
    leds[x] = CRGB(0, 255, 0);  }
  FastLED.show();
  
  } 
  

  if (light == 2){
      for (int x = 81; x <= 160; x = x + 1) {
    leds[x] = CRGB(255, 255, 0);}
    for (int x = 0; x <= 80; x = x + 1) {
    leds[x] = CRGB(0, 0, 0);  }
    for (int x = 161; x <= 256; x = x + 1) {
    leds[x] = CRGB(0, 0, 0);  }
  FastLED.show();
  //delay(500);
  }  
  if (light == 3){
      for (int x = 0; x <= 160; x = x + 1) {
    leds[x] = CRGB(0, 0, 0);}
    for (int x = 161; x <= 256; x = x + 1) {
    leds[x] = CRGB(255, 0, 0);  }
    FastLED.show();
   
  }

}

Code for Processing:

import processing.serial.*;
import osteele.processing.SerialRecord.*;
import processing.video.*;
Serial serialPort;
SerialRecord serialRecord;
SerialRecord sendTime;
PFont myFont;
Movie z1;
Movie z2;
int scoreP1=0;
int scoreP2=0;
long savedTime;
long totalTime = 9000;
void setup() {
  z1 = new Movie(this, "z1.mp4");
  z1.loop();
  z2 = new Movie(this, "z2.mp4");
  z2.loop();
  fullScreen();
  background(#74E0FF);
  savedTime = millis();


  serialPort = new Serial(this, "COM7", 9600);
  sendTime = new SerialRecord(this, serialPort, 1);


  serialRecord = new SerialRecord(this, serialPort, 2);
}

void draw() {
  
  sendTime.send();
  background(#74E0FF);
  blackLight();
  serialRecord.read();
  int value1 = serialRecord.values[0];
  int value2 = serialRecord.values[1];
  
  playVideo();
  
  myFont = createFont("ComicSansMS", 160);
  textFont(myFont);
  textAlign(CENTER, CENTER);
  int scoreGetp1 = value1;
  int scoreGetp2=value2;
  text(scoreP1, 200, 50);
  text(scoreP2, width-230, 50);
  textSize(30);
  scoreP1 = scoreP1+scoreGetp1;
  scoreP2 = scoreP2+scoreGetp2;
  long passedTime = millis() - savedTime;
  blackLight();
//Greenlight
  if (passedTime<4000 && passedTime > 0) {
    greenLight();
    sendTime.values[0] = 1;
  }
//Yellowlight
  if (passedTime>=4000 && passedTime< 6000) {
    yellowLight();
    sendTime.values[0] = 2;
  }
//Redlight
  if (passedTime>=6000 && passedTime <9000) {
    redLight();
    sendTime.values[0] = 3;
    //how game ends: rules
    if (scoreGetp1 !=0) {
      clear();
      fill(255,0,0);
      myFont = createFont("ComicSansMS", 160);
      textFont(myFont);
      textAlign(CENTER, CENTER);
      text("The winner is: P2! ", width/2, height/2-100);
      text("Stand still when red light is up! ", width/2, height/2+100);
      scoreP1 = 0;
      scoreP2 = 0;
      stop();
    }
 
    if (scoreGetp2 != 0) {
      clear();
      fill(255,0,0);
      myFont = createFont("ComicSansMS", 160);
      textFont(myFont);
      textAlign(CENTER, CENTER);
      text("The winner is: P1! ", width/2, height/2-100);
      text("Stand still when red light is up! ", width/2, height/2+100);      
      scoreP1 = 0;
      scoreP2 = 0;
      stop();
    }
  }
   //Reset Game Time
   if (passedTime >= totalTime){
   savedTime = millis();;
   } 
  //How game ends: score
  if (scoreP1 > 30) {
    clear();
    background(255);
    fill(255,0,0);
    myFont = createFont("ComicSansMS", 160);
    textFont(myFont);
    textAlign(CENTER, CENTER);
    text("The winner is: P1! ", width/2, height/2-100);
    text("Congratulations! ", width/2, height/2+100);
      scoreP1 = 0;
      scoreP2 = 0;
      stop();
  }
  if (scoreP2 > 30) {
    clear();
    fill(255,0,0);
    myFont = createFont("ComicSansMS", 160);
    textFont(myFont);
    textAlign(CENTER, CENTER);
    text("The winner is: P2! ", width/2, height/2-100);
    text("Congratulations! ", width/2, height/2+100);
      scoreP1 = 0;
      scoreP2 = 0;
      stop();
  } 
}
void playVideo(){  if (z1.available() == true) {
    z1.read();
  }
  if (z2.available() == true) {
    z2.read();
  }
  image(z1, 0, 0, width/2, height);
  image(z2, width/2, 0,width/2, height);}
  void blackLight(){
noStroke();
fill(0);
circle(width/2,height/5,height/4);
rectMode(CENTER);
rect(width/2,height/2,height/4,height/1.75);
circle(width/2,height*0.8,height/4);
rect(width/2,height/2,height/18,height);}

void redLight(){
fill(255,0,0);
circle(width/2,height/4.5,height/5);
fill(#ADC40A);
circle(width/2,height/2,height/5);
fill(#007905);
circle(width/2,height/1.3,height/5);
}
void greenLight(){
fill(#8E0000);
circle(width/2,height/4.5,height/5);
fill(#ADC40A);
circle(width/2,height/2,height/5);
fill(0,255,0);
circle(width/2,height/1.3,height/5);
}
void yellowLight(){
fill(#8E0000);
circle(width/2,height/4.5,height/5);
fill(#A70046);
fill(255,255,0);
circle(width/2,height/2,height/5);
fill(#007905);
circle(width/2,height/1.3,height/5);
}

Testing the sensor:

Photos of the project:  

The sketch of the animation:

The animation:

Videos of user testing:

Win: Get enough points

Win: Get enough points

Eliminated: break rules (Step when red light is on)

Leave a Reply

Your email address will not be published. Required fields are marked *