Skip to content

Instantly share code, notes, and snippets.

@akshaybaweja
Created November 20, 2019 07:22
Show Gist options
  • Save akshaybaweja/2ea9ce1941b4264e3208985d30e845dd to your computer and use it in GitHub Desktop.
Save akshaybaweja/2ea9ce1941b4264e3208985d30e845dd to your computer and use it in GitHub Desktop.
Processing <> Arduino
import apsync.*; //for syncing data with arduino; SerialEvent fails in processing hence this library helps!!
import processing.serial.*;
import processing.sound.*;
Serial myPort; // Create object from Serial class
AP_Sync streamer;
public int distance;
PImage backdrop, eggo;
PFont light, lightItalic, normal, normalItalic, bold, boldItalic, black;
IntList xCoord = new IntList();
IntList yCoord = new IntList();
IntList types = new IntList();
IntList size = new IntList();
int number = 0;
String audioFile = "Stranger_Things_Title_Sequence_HD_Netflix.mp3";
SoundFile audio;
SoundFile audio1;
SoundFile audio2;
void setup() {
fullScreen();
background(0);
audio = new SoundFile(this, audioFile);
backdrop = loadImage("882548.jpg");
eggo = loadImage("vpIup9y3.png");
audio.loop();
light = createFont("GillSans-Light", 18);
lightItalic = createFont("GillSans-LightItalic", 18);
normal = createFont("GillSans", 18);
normalItalic = createFont("GillSans-Italic", 18);
bold = createFont("GillSans-Bold", 25);
boldItalic = createFont("GillSans-BoldItalic", 25);
black = createFont("GillSans-UltraBold", 18);
String portName = Serial.list()[11];
streamer = new AP_Sync(this, portName, 9600);
distance = 0;
}
void draw() {
if ((int)random(0, 70)>=40) {
xCoord.append((int)random(0, width));
yCoord.append(0);
types.append((int)random(0, 2));
size.append((int)random(50, 120));
number++;
}
image(backdrop, 0, 0, width, height);
fill(255, 71, 26);
textFont( bold);
text("'You look just like ketchup smells!'- Mike", 500, 250);
textFont( boldItalic);
text("'Good, ketchup is dope'- Nancy", 500, 300);
for (int i = 0; i<number-1; i++) {
if (types.get(i) == 0) {
eggos(xCoord.get(i), yCoord.get(i), size.get(i));
if (distance>40) {
yCoord.set(i, yCoord.get(i)+50);
} else {
yCoord.set(i, yCoord.get(i)+distance);
}
}
}
}
void eggos(int x, int y, int s) {
image(eggo, x, y, 70, 70);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment