Pill OVO

IMG_0236-16.jpg

Pill OVO

The one and only interactive Drake face pillow.

See intractable here

https://vimeo.com/149339766

IMG_0243-17.jpg

Code

int valueRead = 0;
int buttonState = 0;
int lastButtonState = 0;

unsigned long currentMillis;
unsigned long pauseMillis;
int millisCounter = 0;

void setup() {
// put your setup code here, to run once:

Serial.begin(9600);
pinMode(4, OUTPUT);
digitalWrite(4, HIGH);
pinMode(5, OUTPUT);
digitalWrite(5, HIGH);
pinMode(6, OUTPUT);
digitalWrite(6, HIGH);
pinMode(7, OUTPUT);
digitalWrite(7, HIGH);
pinMode(8, OUTPUT);
digitalWrite(8, HIGH);
pinMode(9, OUTPUT);
digitalWrite(9, HIGH);

currentMillis = millis();
}

void loop() {
// put your main code here, to run repeatedly:

if(millis() - currentMillis>250)
{
valueRead = analogRead(A0);
int pin = random(6, 9);

Serial.println(analogRead(A0));
if(valueRead > 20){
buttonState = 1;
millisCounter = 0;
}

else {
buttonState = 0;

millisCounter++;
}

// IF INACTIVE FOR 10 SECONDS

if(millisCounter == 120)
{

Serial.println("INACTIVE FOR 10 SECONDS");

pauseMillis = millis();
digitalWrite(5,LOW); // ACTIVATE PIN FOR 30 SECOND PLAY

delay(250);

}

if(millisCounter>120)
{
Serial.println("60 SECOND LOOP");

// digitalWrite(5,HIGH); // DEACTIVATE PIN FOR 30 SECOND PLAYJ

if (millis() - pauseMillis > 60000) // AFTER A MINUTE RESET THE COUNTER
{
millisCounter = 0;
}

}

// IF NOT INACTIVE FOR 10 SECONDS

else
{



if(buttonState == lastButtonState){
for(int i=1; i < 9; i++){
digitalWrite(i, HIGH);
}
}
if(buttonState != lastButtonState){
if (buttonState == 1){
Serial.println(pin);
Serial.println("oh fuck yeah, right there");
digitalWrite(pin, LOW);
delay(250);
//digitalWrite(8, LOW);
}
else if(buttonState == 0){
Serial.println("touch me!");
//digitalWrite(8, HIGH);
for(int i=1; i < 5; i++){
digitalWrite(i, HIGH);
}

}
}

}

lastButtonState = buttonState;

currentMillis = millis();

// END MILLIS LOOP

}

// END LOOP

}