← strona główna

Instalacja interaktywna kosz szok

Instalacja na Wzgórzu Krzemowym w Krakowie, październik 2017 roku

image23

  1. Instalacja w działaniu (reż. Artur Tajber), oficjalna strona wydarzenie: Wzgórze Krzemowe:

  1. Działanie w trakcie wernisażu:

  1. Dźwięki odtwarzane podczas „nieaktywności” (zawierają częstotliwości 37Hz – rezonans blaszanego kosza):

  2. Dźwięki odtwarzane podczas „uaktywnienia”:

  1. Plakat:

Plakat_wzgorze_krzemowe

  1. Kod dla arduino:
/*
 * PCD8544 - Interface with Philips PCD8544 (or compatible) LCDs.
 *
 * Copyright (c) 2010 Carlos Rodrigues <cefrodrigues@gmail.com>
 *
 * To use this sketch, connect the eight pins from your LCD like this:
 *
 * Pin 1 -> +3.3V (rightmost, when facing the display head-on)
 * Pin 2 -> Arduino digital pin 3
 * Pin 3 -> Arduino digital pin 4
 * Pin 4 -> Arduino digital pin 5
 * Pin 5 -> Arduino digital pin 7
 * Pin 6 -> Ground
 * Pin 7 -> 10uF capacitor -> Ground
 * Pin 8 -> Arduino digital pin 6
 *
 * Since these LCDs are +3.3V devices, you have to add extra components to
 * connect it to the digital pins of the Arduino (not necessary if you are
 * using a 3.3V variant of the Arduino, such as Sparkfun's Arduino Pro).
 */

//http://randomnerdtutorials.com/complete-guide-for-nokia-5110-lcd-with-arduino/
#include <PCD8544.h>

#include <CapacitiveSensor.h>
CapacitiveSensor cs_8_9 = CapacitiveSensor(8,9);

//https://github.com/DFRobot/DFRobotDFPlayerMini/blob/master/examples/FullFunction/FullFunction.ino

#include "SoftwareSerial.h"
#include "DFRobotDFPlayerMini.h"

long touchMin = 1000000;
long touchMax = -1000000;

const int numReadings = 10;
int readings[numReadings];      // the readings from the analog input
int ostatnie[numReadings];
int readIndex = 0;              // the index of the current reading
int total = 0;                  // the running total
int average = 0;                // the average

int currVolume = 10;

long lastFire = millis();
long nextFire = 10000;
int maxFireVolume = 25;
int minVolume = 10;

SoftwareSerial mySoftwareSerial(10, 11); // RX, TX
DFRobotDFPlayerMini myDFPlayer;
void printDetail(uint8_t type, int value);

// A custom glyph (a smiley)...
static const byte glyph[] = { B00010000, B00110100, B00110000, B00110100, B00010000 };

static PCD8544 lcd;

#define PIN_SWITCH_1  12
bool switched = false;
int playedTrack = 1;

void setup() {

  pinMode (PIN_SWITCH_1, INPUT_PULLUP);

  lcd.begin(84, 48);
  lcd.createChar(0, glyph);
  lcd.setContrast(70); // 0-127

  mySoftwareSerial.begin(9600);
  Serial.begin(115200);

  Serial.println();
  Serial.println(F("DFRobot DFPlayer Mini Demo"));
  Serial.println(F("Initializing DFPlayer ... (May take 3~5 seconds)"));

  if (!myDFPlayer.begin(mySoftwareSerial)) {  //Use softwareSerial to communicate with mp3.
    Serial.println(F("Unable to begin:"));
    Serial.println(F("1.Please recheck the connection!"));
    Serial.println(F("2.Please insert the SD card!"));
    while(true);
  }
  Serial.println(F("DFPlayer Mini online."));

  myDFPlayer.setTimeOut(500); //Set serial communictaion time out 500ms
  //  myDFPlayer.EQ(DFPLAYER_EQ_NORMAL);
  myDFPlayer.EQ(DFPLAYER_EQ_BASS);
  myDFPlayer.outputDevice(DFPLAYER_DEVICE_SD);

  myDFPlayer.loop(playedTrack);
//  myDFPlayer.loopFolder(15); // !!!!    
//  myDFPlayer.playFolder(15, 4); //play specific mp3 in SD:/15/004.mp3; Folder Name(1~99); File Name(1~255)

  myDFPlayer.volume(10); //Set volume value (0~30)

  cs_8_9.set_CS_AutocaL_Millis(0xFFFFFFFF);     // turn off autocalibrate on channel 1 - just as an example

  for (int thisReading = 0; thisReading < numReadings; thisReading++) {
    readings[thisReading] = 0;
  }

}


void loop() {

  bool switched = digitalRead (PIN_SWITCH_1);
  if (switched) {
    digitalWrite (13, 1);
    if (playedTrack == 1) {
      playedTrack = 2; 
      myDFPlayer.loop(playedTrack);
      // volume max ...
    }
  } else {
    digitalWrite (13, 0);
    if (playedTrack == 2) {
      playedTrack = 1;
      myDFPlayer.loop(playedTrack);
      // ... rest of normal state          
    }
  }

  lcd.setCursor(0, 0);
  lcd.print("cymaticTrash.1");

  lcd.setCursor(0, 5);
  lcd.print(millis()/1000, DEC);
  lcd.write(0);  // write the smiley


  long touch = cs_8_9.capacitiveSensor(10);

  lcd.setCursor(0, 1);
  for(int k=0; k<14; k++) { lcd.write('.'); }
  lcd.setCursor(0, 1);
  lcd.print(currVolume, DEC);

  lcd.setCursor(0, 2);
  for(int k=0; k<14; k++) { lcd.write('.'); }
  lcd.setCursor(0, 2);
  lcd.print(touch, DEC);

  if (touch > touchMax) touchMax = touch;
  if (touch < touchMin) touchMin = touch;

  readings[readIndex] = touch;
  long sum = 0;
  for (int k = 0; k < numReadings; k++) {
    sum = sum + readings[k];
  }
  average = sum/ numReadings;  

  readIndex++;
  if (readIndex >= numReadings) {
    readIndex = 0;
  }

  lcd.setCursor(0, 3);
  for(int k=0; k<14; k++) { lcd.write('.'); }
  lcd.setCursor(0, 3);
  lcd.print(nextFire, DEC);

  lcd.setCursor(0, 4);
  for(int k=0; k<14; k++) { lcd.write('.'); }
  lcd.setCursor(0, 4);
  lcd.print(average, DEC);

  if (touch > 3 * average) {
    fadeinAndOut ();
  }

  // auto fade in, from time to time
  if (millis() - lastFire > nextFire) { 
    currVolume++;
    myDFPlayer.volume(currVolume);
    if (currVolume > maxFireVolume) {
      nextFire = random (500, 15000);
      currVolume = minVolume;
      myDFPlayer.volume(currVolume);
      lastFire = millis();
      // delay needed ???
    }    
  }

  delay(10);

}

int fadeinAndOut () {

  int slow = random (5, 80);

  for (int volume = currVolume; volume < 31; volume++) {

    myDFPlayer.volume(volume); //Set volume value (0~30)
    delay(slow);
    currVolume = volume;

  }

  myDFPlayer.volume(minVolume); //Set volume value (0~30)
  currVolume = minVolume;

}



Koncepcja i realizacja (preparacja kosza, projekt i realizacja układu elektronicznego, strona wizualna, próbki dźwiękowe i kod programu): Marcin Strzelecki