This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//keep track of gifs | |
let currentGif; //the file path | |
let image; //the actual image | |
//API info | |
let APIkey = "3GGsEajJUSgykXGpw4EeN6QYY5w5Ve7G"; | |
let numGif = 25; | |
let queryLeft = "cat"; | |
let queryRight = "dog"; | |
let giphyLeftData; | |
let giphyMiddleData; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Declare a "SerialPort" object | |
let serial; | |
let latestData = "waiting for data"; | |
//sounds | |
let sounds = []; | |
//incoming data from arduino | |
let arduinoData = []; | |
let activeSide; | |
let interval; | |
//logic for when to play sound |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//LED Pins | |
int LEDPins[] = {5, 6, 7, 8, 9}; | |
//Switch Pins | |
int switchPins [] = {12, 11, 2, 3, 4}; | |
//sides | |
int activeSide; | |
int activeSwitchState; | |
int lastActiveSwitchState; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//LED Pins | |
int LEDPins[] = {5, 6, 7, 8, 9}; | |
//Switch Pins | |
int switchPins [] = {12, 11, 2, 3, 4}; | |
//sides | |
int activeSide; | |
int activeSwitchState; | |
int lastActiveSwitchState; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//LED Pins | |
int LEDPins[] = {5, 6, 7, 8, 9}; | |
void setup() { | |
Serial.begin(9600); | |
//LEDS | |
pinMode(LEDPins[0], OUTPUT); | |
pinMode(LEDPins[1], OUTPUT); | |
pinMode(LEDPins[2], OUTPUT); | |
pinMode(LEDPins[3], OUTPUT); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Declare a "SerialPort" object | |
let serial; | |
let latestData = "waiting for data"; | |
//sensor data | |
let factor1, factor2; | |
let sensorValue = []; | |
function setup() { | |
// Instantiate our SerialPort object | |
serial = new p5.SerialPort(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// the setup routine runs once when you press reset: | |
void setup() { | |
Serial.begin(9600); | |
} | |
void loop() { | |
//photoresistor on A0 pin | |
int photoresValue = analogRead(A0); | |
photoresValue *= 0.25; | |
Serial.print(photoresValue); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function setup() { | |
//starter image | |
image = createImg("welcome.gif"); | |
image.class('gif'); | |
//remove and then show new gif | |
button.mousePressed(removeGif); | |
button.mouseReleased(showGif); | |
} | |
function showGif() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//this code goes in the setup | |
for (let i = 0; i < numGif; i++) { | |
catGif.push("/cat-gifs/cat" + i + ".gif"); | |
catDogGif.push("/cat-dog-gifs/catdog" + i + ".gif"); | |
dogGif.push("/dog-gifs/dog" + i + ".gif"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function preload() { | |
for (let i = 0; i < numGif; i++) { | |
catGif.push(loadImage("/cat-gifs/cat" + i + ".gif")); | |
catDogGif.push(loadImage("/cat-dog-gifs/catdog" + i + ".gif")); | |
dogGif.push(loadImage("/dog-gifs/dog" + i + ".gif")); | |
} | |
} |