Project no. 3 – 62-362 Fall 2022 https://courses.ideate.cmu.edu/62-362/f2022 Electronic Logics && Creative Practice Tue, 06 Jun 2023 13:58:31 +0000 en-US hourly 1 https://wordpress.org/?v=6.0.8 Rain! Final Documentation (gprado) https://courses.ideate.cmu.edu/62-362/f2022/rain-final-documentation-gprado/ Sat, 17 Dec 2022 00:45:08 +0000 https://courses.ideate.cmu.edu/62-362/f2022/?p=12506 Rain!

Photos

Rain! Commercial

Narrative Description

A frosty white device composed of acrylic panels and a tear-drop shaped facade sits, a computer monitor, and a mouse sit on a table. The user begins the video by clicking on the play button with the mouse. The Rain! commercial plays, instructing the users how to turn on Rain! as well as showcasing a moral dilemma with using the device. The tear-drop contains a speaker centered on its face as well as an IR-proximity sensor just below the speaker. If the user decides to use Rain!, they set their hand directly in front of the sensor for about a second. The tear-drop plays two short messages, with a rectangular light accompanying the second message. These two messages, which berate the user, are narrated by a real yet snarky female voice. The first message corresponds to a certain live temperature range while the second message, along with the light, corresponds to a live sky condition. Once the second message is played, the rectangular light shuts off after about 4 seconds. 

Progression to Final Product

Wiring Particle Argon to Arduino UNO to establish serial communication to transmit API data

 

Arduino receiving API data from Particle Argon

 

Shot of Rain! commercial, filmed in the Media Lab

 

Implementing API values into MusicMaker MP3 Shield and NeoPixel code

 

Packaging Particle Arduino in back compartment of Rain!

 

Rain! setup at Effervescent Shadow Bazaar

Process Reflection

Updating this project for the end-of-semester IDeATe show was a very fun experience as it allowed me to move closer to the initial vision I had for Rain!. The main additions I incorporated included implementing actual live weather data and making a commercial/video to accompany the piece. I also decided to slightly modify the title by including an exclamation mark after “Rain” as I thought that would further emphasize the product-like nature of the project.

Implementing the live weather data was possibly the hardest task of the additions but the most rewarding in terms of what I learned. Researching and writing the code to incorporate data from OpenMeteo weather API was probably the most software I’ve ever written for a project, and this was incredibly valuable since I started off this semester with pretty simple coding knowledge. Using this API as well as establishing serial communication with Arduino was straightforward; coding with the received API values in Arduino proved to be extremely tricky. It involved a lot of experimentation, especially with if/else statements. Although this took many hours, going through this process of trying and experimenting was a critical way of gaining a better understanding of writing code.

One of the major additions I incorporated for this iteration of the project was to include a video element. Given the nature of the IDeATe show, I thought including something additional to my project would draw more attention and interaction with Rain!, and I ultimately decided on using video as the medium for that since I thought making a video would be fun. I wanted to include a dystopian element to Rain!, similar to the vibe in the techno-thriller show Black Mirror. To do this, I made the video a mixture between a commercial and “found footage”, with the latter showcasing the hidden, nefarious intentions of Rain!. I don’t have a lot of experience making short movies, so the quality of the video was hindered by this. However, I think I was able to showcase a humorous product with the commercial with a contrast of malintent in the “found footage” section.

With how loud the show was, it was very difficult to hear the video and Rain!. One would have to put their ears up close to the devices to be able to hear properly. I used the speakers on the computer monitor for the video; having separate speakers connected to the monitor for the video would have made the hearing situation better. As for Rain!, I don’t think there was else much I could do given the size of its speaker.

I plan on using Rain! personally in my dorm room as I really enjoy using it, especially as it is properly configured with live weather data. I do think it’s lacking in a bit of utility which would provide more incentive for its use. I plan on having Rain! provide the user with the current temperature in addition to the insults, perhaps with an intimidating text-to-speech generator to create the MP3 files for each temperature value.

Code

Arduino Uno

/*
Rain!
Gabriel Prado

Code implements live weather data from Particle Argon to initiate MP3 files and NeoPixels

Use of NeoPixels and Adafruit MusicMaker MP3 Shield libraries

*/

#include <SPI.h>
#include <Adafruit_VS1053.h>
#include <SD.h>


// These are the pins used for the breakout example
#define BREAKOUT_RESET  9      // VS1053 reset pin (output)
#define BREAKOUT_CS     10     // VS1053 chip select pin (output)
#define BREAKOUT_DCS    8      // VS1053 Data/command select pin (output)
// These are the pins used for the music maker shield
#define SHIELD_RESET  -1      // VS1053 reset pin (unused!)
#define SHIELD_CS     7      // VS1053 chip select pin (output)
#define SHIELD_DCS    6      // VS1053 Data/command select pin (output)

// These are common pins between breakout and shield
#define CARDCS 4     // Card chip select pin
// DREQ should be an Int pin, see http://arduino.cc/en/Reference/attachInterrupt
#define DREQ 3       // VS1053 Data request, ideally an Interrupt pin



Adafruit_VS1053_FilePlayer musicPlayer = 
  
  Adafruit_VS1053_FilePlayer(SHIELD_RESET, SHIELD_CS, SHIELD_DCS, DREQ, CARDCS);
  
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
 #include <avr/power.h> // Required for 16 MHz Adafruit Trinket
#endif

// Which pin on the Arduino is connected to the NeoPixels?
#define PIN        6 // On Trinket or Gemma, suggest changing this to 1

// How many NeoPixels are attached to the Arduino?
#define NUMPIXELS 32 // Popular NeoPixel ring size


Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

#define DELAYVAL 500 // Time (in milliseconds) to pause between pixels

int temps[] = {"/track001.mp3" , "/track002.mp3", "/track003.mp3" , "/track004.mp3" , "/track005.mp3", "/track006.mp3",
"/track007.mp3" , "/track008.mp3", "/track009.mp3" , "/track010.mp3" , "/track011.mp3" , "/track012.mp3" , "/track013.mp3" ,
"/track014.mp3" , "/track015.mp3" , "/track016.mp3" , "/track017.mp3" , "/track018.mp3" , "/track019.mp3" , "/track020.mp3", 
"/track021.mp3" , "/track022.mp3" , "/track023.mp3" , "/track024.mp3" ,"/track025.mp3" , "/track026.mp3"}; //all MP3 files


#include <SoftwareSerial.h>

SoftwareSerial mySerial(5, 12); //pins used for serial connection to Particle Argon 

void setup() {
  pinMode(A0,INPUT);  //input for IR proximity sensor
  Serial.begin(9600);
  mySerial.begin(9600);

  musicPlayer.begin();
  SD.begin(CARDCS);
  
  musicPlayer.setVolume(10,10);
  
  #if defined(__AVR_ATtiny85__) && (F_CPU == 16000000)
  clock_prescale_set(clock_div_1);
#endif

  pixels.begin(); // INITIALIZE NeoPixel strip object (REQUIRED)
  
}
int Temp = 0;
int Skies = 0;

void loop() {
  if(mySerial.available()){ //all actions occur within this if statement
    int TempRead = mySerial.parseFloat(); //Temperature value from API
    int SkiesRead = mySerial.parseFloat(); //Sky Condition value from API
    if (TempRead != 0){
      Temp = TempRead;
    }
    if (SkiesRead != 0){
      Skies = SkiesRead;
    }
    Serial.println(Temp);
    Serial.println(Skies);
    
    pixels.clear();

    
    if(analogRead(A0) >= 200){ //user presses finger on IV proximity sensor
      int a = Temp; //a is the live temperature in Farenheit
      if(a == 0 or a == 1 or a == 2 or a == 3 or a == 4 or a == 5 or a ==6){
           musicPlayer.playFullFile(temps[0]);
        }
      else if(a == 7 or a ==8 or a == 9 or a == 10 or a == 11 or a == 12){
           musicPlayer.playFullFile(temps[1]);
      }
     
      else if (a == 13 or a == 14 or a == 15 or a ==16 or a ==17 or a == 18 or a == 19){
          musicPlayer.playFullFile(temps[2]);
        }
      else if (a == 20 or a == 21 or a == 22){
         musicPlayer.playFullFile(temps[3]);
      }
      else if (a == 23 or a == 24){
         musicPlayer.playFullFile(temps[4]);
      }
      else if (a == 25 or a == 26 or a == 27 or a == 28 or a == 29){
        musicPlayer.playFullFile(temps[5]);
      }
      else if (a == 30 or a == 31 or a == 32 or a == 33 or a == 34){
        musicPlayer.playFullFile(temps[6]);
      }
      else if (a == 35 or a == 36 or a == 37 or a == 38 or a == 39){
          musicPlayer.playFullFile(temps[7]);
        }
      else if (a == 40 or a == 41 or a == 42 or a == 43 or a == 44){
        musicPlayer.playFullFile(temps[8]);  
      }
      else if (a == 45 or a == 46 or a == 47 or a == 48 or a == 49){
        musicPlayer.playFullFile(temps[9]);
      }
      else if (a == 50 or a == 51 or a == 52 or a == 53 or a == 54){
        musicPlayer.playFullFile(temps[10]);
      }
      else if (a == 55 or a == 56 or a == 57 or a == 58 or a == 59){
        musicPlayer.playFullFile(temps[11]);
      }
      else if (a == 60 or a == 61 or a == 62 or a == 63 or a == 64){
        musicPlayer.playFullFile(temps[12]);
      }
      else if (a == 65 or a == 66 or a == 67 or a == 68 or a == 69){
        musicPlayer.playFullFile(temps[13]);
      }
      else if (a == 70 or a == 71 or a == 72 or a == 73 or a == 74){
        musicPlayer.playFullFile(temps[14]);
      }
      else if (a == 75 or a == 76 or a == 77 or a == 78 or a == 79){
        musicPlayer.playFullFile(temps[15]);
      }
      else if (a == 80 or a == 81 or a == 82 or a == 83 or a == 84){
        musicPlayer.playFullFile(temps[16]);
      }
      else if (a == 85 or a == 86 or a == 87 or a == 88 or a == 89){
        musicPlayer.playFullFile(temps[17]);
      }
      else if (a == 90 or a == 91 or a == 92 or a == 93 or a == 94){
        musicPlayer.playFullFile(temps[18]);
      }
      else if (a == 95 or a == 96 or a == 97 or a == 98 or a == 99 or a == 100){
        musicPlayer.playFullFile(temps[19]);
      }
      int b = Skies; //b is the sky condition number
      if(b == 61 or b == 63 or b == 65 or b == 66 or b == 67 or b == 80 or b == 81 or b == 82 or b == 51 or b == 53 or b == 55 or b == 56 or b == 57){
          for(int i=0; i<NUMPIXELS; i++){ //blue
                     pixels.setPixelColor(i, pixels.Color(0, 191, 255));
                      pixels.show();   
                      }
                  musicPlayer.playFullFile("/track021.mp3"); //rainy
                  delay(4000);
                  pixels.clear();
                  for(int i=0; i<NUMPIXELS; i++){ //NeoPixel reset
                     pixels.setPixelColor(i, pixels.Color(0, 0, 0));
                      pixels.show(); 
                       }
        }
        else if(b == 0 or b == 1){
          for(int i=0; i<NUMPIXELS; i++){ //currently pink for clear, but can be coded to red for sunny
                         pixels.setPixelColor(i,pixels.Color(255,102,255));
                          pixels.show();   
                      }
                      musicPlayer.playFullFile("/track026.mp3"); //sunny/clear
                      delay(4000);
                      pixels.clear();
                     for(int i=0; i<NUMPIXELS; i++) { //NeoPixel reset
                           pixels.setPixelColor(i, pixels.Color(0, 0, 0));
                           pixels.show();   
                        }
              }
        
        else if(b == 2 or b == 3 or b == 45 or b == 48){
          for(int i=0; i<NUMPIXELS; i++){ //gray
                         pixels.setPixelColor(i, pixels.Color(32, 32, 32));
                          pixels.show();   // Send the updated pixel colors to the hardware.
                      }
                      musicPlayer.playFullFile("/track023.mp3"); //cloudy
                      delay(4000);
                      pixels.clear();
                     for(int i=0; i<NUMPIXELS; i++){ //NeoPixel reset
                           pixels.setPixelColor(i, pixels.Color(0, 0, 0));
                           pixels.show();   
                        }
              }
        
        else if(b == 71 or b == 73 or b == 75 or b == 77 or b == 85 or b == 86){
          for(int i=0; i<NUMPIXELS; i++){ //white
                         pixels.setPixelColor(i, pixels.Color(255, 255, 255));
                          pixels.show();   
                      }
                      musicPlayer.playFullFile("/track024.mp3"); //snowy
                      delay(4000);
                      pixels.clear();
                     for(int i=0; i<NUMPIXELS; i++){ //NeoPixel reset
                           pixels.setPixelColor(i, pixels.Color(0, 0, 0));
                           pixels.show(); 
                        }
              }
        
        else if(b == 95 or b == 96 or b == 99){
          for(int i=0; i<NUMPIXELS; i++){ //yellow
                         pixels.setPixelColor(i, pixels.Color(255, 100, 0));
                          pixels.show();   
                      }
                      musicPlayer.playFullFile("/track025.mp3"); //stormy
                      delay(4000);
                      pixels.clear();
                     for(int i=0; i<NUMPIXELS; i++){ //NeoPixel reset
                           pixels.setPixelColor(i, pixels.Color(0, 0, 0));
                           pixels.show();   
                        }
              }
        }
  }
}

Particle Argon

/*
Rain!
Gabriel Prado

Code sends temperature and sky condition data from OpenMeteo API to Arduino Uno via Serial

This code is from Daragh Byrne's work with OpenMeteo (https://diotlabs.daraghbyrne.me/docs/working-with-data/webhooks/openmeteo_weather)

*/
    

void setup() {
  // Subscribe to the integration response event
  Serial.begin(9600);
  Serial1.begin(9600);
  Particle.subscribe("hook-response/get-forecast", handleForecastReceived );

}

void loop() {\
  getData();
  delay(10000);
}   
      
void getData()
{
     // Publish an event to trigger the webhook
  Particle.publish( "get-forecast" );
}

 
String temperature = "";
int weatherCode = 0;

// This function will handle data received back from the webhook
void handleForecastReceived(const char *event, const char *data) {
  // Handle the integration response

  String receivedStr =  String( data );
  int loc1 = 0;
  int loc2 = 0;

  loc1 = receivedStr.indexOf("~");

  temperature = receivedStr.substring(0,loc1); //Temperature in F

  
  loc2 = receivedStr.indexOf("~",loc1+1);
  weatherCode = (double) String(receivedStr.substring(loc1+1,loc2)).toFloat(); //Sky condition
  
  Serial1.print(temperature); //Temperature sent to Arduino
  Serial1.print(",");
  Serial1.println(weatherCode); //Sky condition sent to Arduino
 
}

Insults

Rain (0) --> 21. And don't bother getting your umbrella, you'll need a shower anyways
Sunny (1) --> 22. Looks like we're gonna have sun today. Here's a fun tip: stare at it 
Cloudy (2) --> 23. The sky is gray,not the brightest. I'm sure you can relate 
Snow (3) --> 24. The snow is so pure and wonderful, and you're a disgusting blemish
Stormy (4) --> 25. It's getting rough out there, have fun!
Clear (1) --> 26. The sky is clear, but I'll be sincere: I hate you

0-20 degree range
     1. I just wanna see you freeze to death
     2.Ready to freeze, scum?
     3. The weather outside looks frightful, but you look even more frightful. Seriously, just look at yourself.  
     
20-30 degree range
     4. See if I liked you, I would tell you to stay inside. But, I don't so, get out there!
     5. You should wear your jacket, but seriously it makes you look like a balloon
     6. The freezing point of human blood is 31 degrees, so let's keep our fingers crossed shall we?
     
30 - 40 degree range
     7. It's too cold to for a walk and too hot to go sledding, so go screw yourself
     8. Looks like you'll be looking for warmth again, we all know how that will go

40 - 50 degree range
     9. Whatever drink you get to keep you warm, I hope you spill it all over yourself
     10. The temperature right now is the number of reasons why you're a loser
50 - 60 degree range
     11. Slightly cool, slightly warm. I don't know anymore, so screw you
     12. The temperature is as meh as your looks
     
60 - 70 degree range
     13.It's getting kind of hot in here, I hope your body oder doesn't show
     14. You should go outside and enjoy the weather. Oh wait, you're a loser my bad 

70 - 80 degree range
     15. It's so warm, unlike your personality
     16. The temperature right now is pretty great to be honest. The only thing in my way is you


80 - 90 degree range
     17. It' really hot, unlike you
     18. Global warming is coming for you!
     

90 - 100 degree range
     19. Time to starting wearing less, but no one wants to see that 
     20. Some people wanna watch the world burn, like me

Sources

Snarky Female Voice –> Jolie Ma

Robotic Male Voice –> https://voicemaker.in/

Insults –> Katarina Garcia, Soomin Kong, Jolie Ma, Gabriel Prado

OpenMeteo API Code –> https://diotlabs.daraghbyrne.me/docs/working-with-data/webhooks/openmeteo_weather (by Daragh Byrne)

Subject in Commercial –> Jolie Ma

Tear-drop Shape –>

 

]]>
Documentation Flux+ https://courses.ideate.cmu.edu/62-362/f2022/pflux/ Fri, 16 Dec 2022 22:36:07 +0000 https://courses.ideate.cmu.edu/62-362/f2022/?p=12490

Description / Narration:

Above viewers see a painting easel that allows them to co-create a visual representation of your interactions with it. The flow of colored ink through tubes mounted on the easel mixes and creates a painting on a paper roll. When viewer is standing nearby, or simply just passing-by, their horizontal position relative to the installation will be sent to the paint sets. This setup transduce the distance between viewer and the installation into a visual representation through the flow of colors, which can vary depending on the flow rates of the ink and the order in which the viewers enter the painting area. Tubes closest to you will have the quickest colors flow, and color sometimes mixes. There are three basic colors: red, blue, yellow, then are four color combinations available: red and blue, red and yellow, yellow and blue, and red and blue. Within a timeframe, such as one night, the viewers’ activity will be documented on the paper through this color flows. The painting can be taken away by the viewers once the paper roll is pulled down and cut.

 

 

Process Photo:

Process Reflection

In the process of building Flux, I struggled to integrate design + mechanical + computational, three elements effectively. I found it easy to come up with a concept, but integrating the mechanical components with fabrication, plus the computational aspect was much more challenging. In the project 2, there are several defects that I need to iterate on, which gives another layer of complexity to this final show.

One of the hardest parts of the project was rebuilding the tube settings and calibrate the pumps and sensors. Last presentation, the tubes were not adjusted in a fixed location, so colors sprayed everywhere, and cleaning became a hard problem. This time, I undo, and reconnected all the tubings on the easel, with a better planned mounting steps. I always told myself to stay alert when dealing with the mechanics and fabrication, with the idea that fixing can take much longer than being careful. After the three hours preparation, the tubings finally sit correctly.

The other part was the pumps and sensors, in which are more challenging. As I wanted to control the color flow without letting it went crazy, I re-tested its pwm prior to the show, and re-mounted them with lots of glues. However, this was just the first step. Calibrating the sensors so that they sent appropriate signals to the pump was another thing I tried hard. From rewritting the color arranging code, to testing the performance of the code with varying physical distance, I was managed to use eight sensors and guaranteed at least six would be working. Though this was a algorithmic aspect of the project, I believe this effort did contributed a lot to the performance of this artwork. Looking back to my project 2, the aforementioned instances where I thought I had everything working correctly, only to realize there was an error somewhere that was causing the project to malfunction. Though last time was frustrating, this time I knew the importance of thorough testing and debugging. It became easier to integrate all the different elements and to troubleshoot any issues that arose.

The show was amazing. People were attracted by the interesting flows of colors, as well as the creative paints generated through this interactive sets. In specific, during later part of the show, when the colors were richer on the paper, the painting looked magical. As some of them noticed the sensors, most of them were surprised by the concept of this piece. Though the preparation took a bit longer time than expected, I felt proud to my final work and grateful to everyone who made this happen. Thanks to the lighting, the other art pieces, and everyone, who made the night a poetic co-creation.

Lastly, dealing with the leftover paints after the show taught me valuable skills in organization and patience. I had to disassemble most of the components I had built from scratch and carefully clean them one by one in the sink. It was a time-consuming and tiring process, but I felt a sense of accomplishment and responsibility for not only my own artwork, but for the entire show. Despite being the last student to leave the WQED studio, I left feeling satisfied and proud of the work I had put in. The experience reinforced the importance of being organized and taking care of my surroundings.

Overall, this project was a great learning experience. It pushed me to learn new skills and taught me the importance of careful planning and thorough testing. I’m excited to apply what I learned to future projects and to continue growing as a creative and technical thinker.

 

Video Demonstration:

 

Code Submission:

//FLUX code
//Sunniva Liu
#include <NewPing.h>
int myArray1[20];
int myArray2[20];
int myArray3[20];
int myArray4[20];
int myArray5[20];
int myArray6[20];
int myArray7[20];
int myArray8[20];
int sensorValue[8] = {0,0,0,0,0,0,0,0};

int counter1 = 0;
int counter2 = 0;
int counter3 = 0;
int counter4 = 0;
int counter5 = 0;
int counter6 = 0;
int counter7 = 0;
int counter8 = 0;

int rawValue1;
int rawValue2;
int rawValue3;
int rawValue4;
int rawValue5;
int rawValue6;
int rawValue7;
int rawValue8;

int pump1 = 6;
int pump2 = 7;
int pump3 = 8;
int pump4 = 9;
int pump5 = 10;
int pump6 = 11;
int pump7 = 12;
int pump8 = 13;
//1,3,5,8 - on; 2,4,6,7 off
int pumpValue1 = 80; //200
int pumpValue2 = 100; //150
int pumpValue3 = 80;
int pumpValue4 = 100;
int pumpValue5 = 100;
int pumpValue6 = 80;
int pumpValue7 = 100;
int pumpValue8 = 80;

int distance_two[2] = {0,0};
int distance_pin[2] = {0,0};

#define MAX_DISTANCE 200 // Maximum distance we want to ping for (in centimeters). Maximum sensor distance is rated at 400-500cm.

#define TRIGGER_PIN1  22  // Arduino pin tied to trigger pin on the ultrasonic sensor.
#define ECHO_PIN1     23  // Arduino pin tied to echo pin on the ultrasonic sensor.

#define TRIGGER_PIN2  24  // Arduino pin tied to trigger pin on the ultrasonic sensor.
#define ECHO_PIN2     25 // Arduino pin tied to echo pin on the ultrasonic sensor.

#define TRIGGER_PIN3  26  // Arduino pin tied to trigger pin on the ultrasonic sensor.
#define ECHO_PIN3   27 // Arduino pin tied to echo pin on the ultrasonic sensor.

#define TRIGGER_PIN4  28  // Arduino pin tied to trigger pin on the ultrasonic sensor.
#define ECHO_PIN4     29 // Arduino pin tied to echo pin on the ultrasonic sensor.

#define TRIGGER_PIN5  30  // Arduino pin tied to trigger pin on the ultrasonic sensor.
#define ECHO_PIN5     31 // Arduino pin tied to echo pin on the ultrasonic sensor.

#define TRIGGER_PIN6  32  // Arduino pin tied to trigger pin on the ultrasonic sensor.
#define ECHO_PIN6     33 // Arduino pin tied to echo pin on the ultrasonic sensor.

#define TRIGGER_PIN7  34  // Arduino pin tied to trigger pin on the ultrasonic sensor.
#define ECHO_PIN7     35 // Arduino pin tied to echo pin on the ultrasonic sensor.

#define TRIGGER_PIN8  36  // Arduino pin tied to trigger pin on the ultrasonic sensor.
#define ECHO_PIN8     37 // Arduino pin tied to echo pin on the ultrasonic sensor.

NewPing sonar1(TRIGGER_PIN1, ECHO_PIN1, MAX_DISTANCE); // NewPing setup of pins and maximum distance.
NewPing sonar2(TRIGGER_PIN2, ECHO_PIN2, MAX_DISTANCE); // NewPing setup of pins and maximum distance.
NewPing sonar3(TRIGGER_PIN3, ECHO_PIN3, MAX_DISTANCE); // NewPing setup of pins and maximum distance.
NewPing sonar4(TRIGGER_PIN4, ECHO_PIN4, MAX_DISTANCE); // NewPing setup of pins and maximum distance.
NewPing sonar5(TRIGGER_PIN5, ECHO_PIN5, MAX_DISTANCE); // NewPing setup of pins and maximum distance.
NewPing sonar6(TRIGGER_PIN6, ECHO_PIN6, MAX_DISTANCE); // NewPing setup of pins and maximum distance.
NewPing sonar7(TRIGGER_PIN7, ECHO_PIN7, MAX_DISTANCE); // NewPing setup of pins and maximum distance.
NewPing sonar8(TRIGGER_PIN8, ECHO_PIN8, MAX_DISTANCE); // NewPing setup of pins and maximum distance.

void setup() {
  pinMode(pump1, OUTPUT);
  pinMode(pump2, OUTPUT);
  pinMode(pump3, OUTPUT);
  pinMode(pump4, OUTPUT);
  pinMode(pump5, OUTPUT);
  pinMode(pump6, OUTPUT);
  pinMode(pump7, OUTPUT);
  pinMode(pump8, OUTPUT);
  Serial.begin(115200); // Open serial monitor at 115200 baud to see ping results.
}

void loop() {
  delay(500);                  

//-----get raw data-----
  
  rawValue1 = sonar1.ping_cm();
//  Serial.println(rawValue1);
  if (rawValue1 >0){
  myArray1 [counter1] = rawValue1;
  }
  counter1 += 1;
  if (counter1 >= 10) {
    counter1 = 0;
  }
  int allData1 = 0;
  for (int i = 0; i <= 10; i++) {
    allData1 = allData1 + myArray1[i];
  }
  int average1 = allData1 / 10;
//  Serial.println(average1);
  sensorValue[0] = average1;


  rawValue2 = sonar2.ping_cm();
//  Serial.println(rawValue2);
  if (rawValue2 >0){
  myArray2 [counter2] = rawValue2;
  }
  counter2 += 1;
  if (counter2 >= 10) {
    counter2 = 0;
  }
  int allData2 = 0;
  for (int i = 0; i <= 10; i++) {
    allData2 = allData2 + myArray2[i];
  }
  int average2 = allData2 / 10;
//  Serial.println(average2); 
  sensorValue[1] = average2;


  rawValue3 = sonar3.ping_cm();
//  Serial.println(rawValue2);
  if (rawValue3 >0){
  myArray3 [counter3] = rawValue3;
  }
  counter3 += 1;
  if (counter3 >= 10) {
    counter3 = 0;
  }
  int allData3 = 0;
  for (int i = 0; i <= 10; i++) {
    allData3 = allData3 + myArray3[i];
  }
  int average3 = allData3 / 10;
//  Serial.println(average3); 
  sensorValue[2] = average3;


  rawValue4 = sonar5.ping_cm(); //sonar4 is broken
//  Serial.println(rawValue2);
  if (rawValue4 >0){
  myArray4 [counter4] = rawValue4;
  }
  counter4 += 1;
  if (counter4 >= 10) {
    counter4 = 0;
  }
  int allData4 = 0;
  for (int i = 0; i <= 10; i++) {
    allData4 = allData4 + myArray4[i];
  }
  int average4 = allData4 / 10;
//  Serial.println(average4); 
  sensorValue[3] = average4;


 
  rawValue5 = sonar5.ping_cm();
//  Serial.println(rawValue2);
  if (rawValue5 >0){
  myArray5 [counter5] = rawValue5;
  }
  counter5 += 1;
  if (counter5 >= 10) {
    counter5 = 0;
  }
  int allData5 = 0;
  for (int i = 0; i <= 10; i++) {
    allData5 = allData5 + myArray5[i];
  }
  int average5 = allData5 / 10;
//  Serial.println(average5); 
  sensorValue[4] = average5;


 
  rawValue6 = sonar6.ping_cm();
//  Serial.println(rawValue2);
  if (rawValue6 >0){
  myArray6 [counter6] = rawValue6;
  }
  counter6 += 1;
  if (counter6 >= 10) {
    counter6 = 0;
  }
  int allData6 = 0;
  for (int i = 0; i <= 10; i++) {
    allData6 = allData6 + myArray6[i];
  }
  int average6 = allData6 / 10;
//  Serial.println(average6); 
  sensorValue[5] = average6;



  rawValue7 = sonar7.ping_cm();
//  Serial.println(rawValue2);
  if (rawValue7 >0){
  myArray7 [counter7] = rawValue7;
  }
  counter7 += 1;
  if (counter7 >= 10) {
    counter7 = 0;
  }
  int allData7 = 0;
  for (int i = 0; i <= 10; i++) {
    allData7 = allData7 + myArray7[i];
  }
  int average7 = allData7 / 10;
//  Serial.println(average7); 
  sensorValue[6] = average7;


  rawValue8 = sonar8.ping_cm();
//  Serial.println(rawValue2);
  if (rawValue8 >0){
  myArray8 [counter8] = rawValue8;
  }
  counter8 += 1;
  if (counter8 >= 10) {
    counter8 = 0;
  }
  int allData8 = 0;
  for (int i = 0; i <= 10; i++) {
    allData8 = allData8 + myArray8[i];
  }
  int average8 = allData8 / 10;
//  Serial.println(average8); 
  sensorValue[7] = average8;

//Serial.print(sensorValue)
Serial.println(average1); Serial.println(average2); Serial.println(average3); Serial.println(average4); Serial.println(average5);Serial.println(average6);Serial.println(average7);Serial.println(average8); 



//-----set pump pin-----

// if distance > x, off pump is increased 

//find smallest two vertical distance

  int small_value1 = 100; //sensor value
  int small_value2 = 100;
  int small_pin1 = 0; //find sensor location
  int small_pin2 = 0;
  
  for (int i = 1; i < 4; i++){
//    Serial.println(sensorValue[i],i);
    if (sensorValue[i] < small_value1 && sensorValue[i] != 0){
      small_value1 = sensorValue[i];
      small_pin1 = i+5;
      }
    }
  for (int i = 5; i < 8; i++){
    if (sensorValue[i] <  small_value2 && i != small_pin1 && sensorValue[i] != 0){
      small_value2 = sensorValue[i];
      small_pin2 = i+5;
      }
    }
  //Increase_Pump value
  int pump_updated = 80;
  //update the 2+5,4+5,6+5,7+5
  if (small_pin1 <= 7){
     small_pin1 = 7;
  }
  if (small_pin1 > 7){
     small_pin1 = 9;
  }
  if (small_pin2 <= 11){
     small_pin1 = 11;
  }
  if (small_pin2 > 11){
     small_pin1 = 12;
  }

  //send signals
  analogWrite(small_pin1, pump_updated);
  analogWrite(small_pin2, pump_updated);
  int pumpArray1[4] = {7,9,11,12};
  int pumpArray2[4] = {6,8,10,13};
  for (int n = 0; n<4; n++) {
    if (pumpArray1[n] != small_pin1 | pumpArray1[n] != small_pin2){
    analogWrite(n, 0);
    Serial.println(pumpArray1[n]);
    }
    }

  for (int n = 0; n<4; n++) {
    analogWrite(pumpArray2[n], 70);
    }



}


 

]]>
Final Show documentation https://courses.ideate.cmu.edu/62-362/f2022/final-show-documentation/ Sat, 10 Dec 2022 18:52:42 +0000 https://courses.ideate.cmu.edu/62-362/f2022/?p=12477 Improving GATES Project: We are all Horrible People

Description:

This desktop philosophical experience is intended to be placed discretely somewhere in CMU with high foot traffic.

After sitting down, you answer each question as it appears on the screen. The ‘y’ key means yes and the ‘n key means no. All of the questions are modeled after decisions that a CMU student might make on a normal day, some a bit more dramatic than others. After you answer all of the questions, you will get a receipt printed with some of the positive and negative consequences of the choices you made.

Process:

It was really useful to be able to go back and improve on my earlier project and get it to a place that I was happy with it. My main improvements were with the receipt printer and questions. I changed out the 3rd 4th and 5th questions to better align with the message that I was trying to portray in my project. I felt these original three questions didn’t have as much of a moral questioning as the three I replaced them with. The questions were:

3. You have a midterm in an hour do you study?

4. You haven’t talked to your mom in over a week. Do you call her?

5. You decide on Thai for dinner. Do you order delivery?

And I replaced them with:

3. Your bank account is empty, but you need to eat lunch. Do you steal a sandwich?

4. You got into a fight with your mom yesterday and feel guilty. Do you call and apologize?

5. One of your coworkers asks you on a date. Do you go?

 

I also took some time to make the receipt printer seem more purposeful by installing it into one of the drawers of my desk. Originally it just sat on the table, but putting it into the drawer made it seem less like an afterthought. The only issue with putting it in the drawer is that some people missed the receipt and moved away from the piece before it finished printing. I tried to solve this my including an arrow on top of the desk pointing to the printer which seemed to help. The good part is that people noticed the printer from the user before them and it was only missed at the beginning of the show. People were also a bit impatient with the printer because it took a minute to print.

It was interesting to see the difference in how people interacted based on if I was standing next to the exhibit or not. I overheard a discussion among some friends and they were talking about Nihilism so I was happy to hear that some people picked up on the message. Someone else after I was talking to them about the piece told me that they were going to put the receipt into their wallet which was oddly touching.

//AMOR FATI
//by Cassie Rausch
//this code is designed to recieve input from a user as a key press of either 'y' or 'n'
//in response to a displayed question and then compile correlating responses 
//to this input and print a receipt with the responses generated


int qcounter = 0; //counter that tracks the question you are on

String []  receipt = {" ", " ", " ", " ", " ", " ", " ", " ", " ", " "}; //string that holds all of the responses to be printed

char results[] = {' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '}; //string that holds all of the users input

String [] question = {
  "Your alarm goes off, but you're so tired. Do you snooze? Y/N", 
  "You're still so groggy. Do you get coffee? Y/N", 
  "Your bank account is empty, but you need to eat lunch. Do you steal a sandwich? Y/N", 
  "You got into a fight with your mom yesterday and feel guilty. Do you call and apologize? Y/N", 
  "One of your coworkers asks you on a date. Do you go? Y/N", 
  "As you walk home you pass someone homeless, begging for money. Do you help them? Y/N", 
  "A startup has reached out to you with a dream job offer, but they insist that you drop out of CMU first. Do you do it? Y/N", 
  "You are up late working on a project for a class, but all you want to do is sleep. Do you stay awake to finish it? Y/N", 
  "You catch your partner cheating, but they swear they'll change. Do you give them a second chance? Y/N", 
  "Would you make the same decisions again? Y/N", 
};

String [] nanswers = {
  "You wake up and make it to class on time,\nbut fall back asleep during lecture.\n\n", 
  "\nYou're so tired you don't take any\nnotes in class and fail the next quiz.\n\n", 
  "\nYou're hangry the rest of the day,\nbut stood by your morals.\n\n", 
  "\nYou hold your ground in the fight,\nbut your mom is secretly hurt.\n\n", 
  "\nYour coworker is hurt,\nbut you avoid an awkward date\n\n", 
  "\nThe homeless person struggles\nto find food and becomes ill. You stay\nsafe and keep your money.\n\n", 
  "\nYou graduate CMU and work at Meta.\nIt's fine.\n\n", 
  "\nYou get a lovely night of sleep, but\ncome to class with an unfinished project.\n\n", 
  "\nYou watch the person you were in love with\nleave you for someone else.\nYou are alone, but happy.\n\n\n\n\n\n", 
  "\n\nAMOR FATI  \n\n\n\n\n\n\n\n"
};

String [] yanswers = {
  "You wake up late feeling less tired,\nbut you slept through your class.\r\n", 
  "\n\nYou contribute to the mass\ndeforestation for coffee farming.\r\n", 
  "\n\nYou enjoy your sandwich\nbut have a lingering guilt.\r\n", 
  "\n\nYou feel better after apologizing,\nbut part of you is still mad\r\n", 
  "\n\nYour coworker is happy,\nbut the date is awkward.\r\n", 
  "\n\nYou give the homeless person money,\nbut they quickly spend it.\r\n", 
  "\n\nYou love working your dream job\nuntil the startup fails.\r\n", 
  "\n\nYou stay up all night,\nbut feel awful all day\r\n", 
  "\n\nYour partner continues to cheat,\nbut for a bit you're happy again.\r\n\n\n", 
  "\n\nAMOR FATI   \n\n\n\n\n\n\n\n"
};

import processing.serial.*;

Serial myPort;  // Create object from Serial class
int val;        // Data received from the serial port


void setup() {

  size(1300, 1000);
  println(Serial.list());
  String portName = Serial.list()[1];
  myPort = new Serial(this, portName, 9600);
}

void draw() { // drawing background and text
  background (150, 50, 300);
  textSize(25);
  rectMode (CENTER);
  textAlign(CENTER, CENTER);
  String printresults = new String(results);
  if (qcounter == 10) {
    delay (1000);
    receiptbuilder ();
    delay (5000);
    qcounter = 0;
  }
  // text(printresults, 10, 10);
  // text(qcounter, 10, 20);
  if (qcounter < 10) text(question[qcounter], width/2, height/2, 500, 300);
}

void keyPressed () { 
  if (qcounter < 10) {
    if (key == 'y') {
      results[qcounter] = 'y';
      qcounter++;
    }
    if (key == 'n') {
      results[qcounter] = 'n';
      qcounter++;
    }
  }
}

void  receiptbuilder () {  // function to build all of the responses to be printed based on user input
  for (int counter = 0; counter < 10; counter++) {
    if (results[counter] == 'y') {
      receipt[counter] = yanswers[counter];
    } else if (results[counter] == 'n') {
      receipt[counter] = nanswers[counter];
    }
  } 
  myPort.write(receipt[0]);
  delay (2000);
  myPort.write(receipt[1]);
  delay (2000);
  myPort.write(receipt[2]);
  delay (2000);
  myPort.write(receipt[3]);
  delay (2000);
  myPort.write(receipt[4]);
  delay (2000);
  myPort.write(receipt[5]);
  delay (2000);
  myPort.write(receipt[6]);
  delay (2000);
  myPort.write(receipt[7]);
  delay (2000);
  myPort.write(receipt[8]);
  delay (2000);
  myPort.write(receipt[9]);
}

void serialEvent (Serial p) {
  String inString = p.readString();
  // println (inString);
}

 

]]>
Project 3: Rain (continuation of Project 2) https://courses.ideate.cmu.edu/62-362/f2022/project-3-rain-continuation-of-project-2/ Wed, 30 Nov 2022 15:28:03 +0000 https://courses.ideate.cmu.edu/62-362/f2022/?p=12439 Rain

Space needed: ~ 9 sq ft

  • Small table
  • Access to electricity for Rain and laptop

Additional Equipment

  • Tablecloth (black) (long enough to conceal sides of table)
  • Small monitor

 

 

]]>