The Galaxy Glove

Making the Galaxy Glove!

 

The Galaxy Glove Kit directly takes advantage of specific gesture and proximity as a means of haptic exploration. Intentional gesture, mirrored in the premise of intentional making and completed action for assault survivors, plays a vital role in enabling embodiment and empowerment in the user. The expressive feedback is provided in an adaptable code sample that allows the user to enact change in a visual environment. The example was inspired to provide a sense of possibility, optimism, wonder, and playfulness.

Before Getting Started

Download Arduino – Arduino is the open source software we will use to program these kits to do the cool things we want them to do! The code provided with the kit is a starter sample so that your kit works as intended but you are encouraged to learn, play, experiment and remix all you want!

Visit Arduino to learn more ways to use and explore!

Download Processing – Processing is a flexible software sketchbook and a language for learning how to code within the context of the visual arts. Since 2001, Processing has promoted software literacy within the visual arts and visual literacy within technology. There are tens of thousands of students, artists, designers, researchers, and hobbyists who use Processing for learning and prototyping.

Visit Processing to learn more ways to creatively code!

What You Will Need

1 x Glove – you can find these for a couple dollars at almost any retail store or if you are like me, you have a bunch of non-matching gloves in different crevices of my dresser.

1 x Wire Cutter

Micro USB-B cable – (purchase)

 

The Galaxy Glove Kit Components

4H_GG_DocuDir

1 x Breadboard (purchase)

1 x ProMicro(3.3v/8mhz) (purchase)

1 x Gesture Sensor (purchase)

4 Wires (purchase)

1 Micro-USB (purchase)

 

Directions

 

1.) Place the ProMicro and the Gesture Sensor into the breadboard.

5H_GG_DocuDir

Make sure that none of the pins are on the same row. The ProMicro must stick off the edge for all the pins to fit. This example has one column of holes between the ProMicro and the Gesture Sensor

 

2.) Wire the Gesture Sensor

8H_GG_DocuDir

6H_GG_DocuDir

7H_GG_DocuDir

galaxy

 

1 Black Wire from the ProMicro GND to the Gesture Sensor Ground Pin

1 Red Wire from the ProMicro VCC to the Gesture Sensor VCC Pin

1 Green Wire from the ProMicro 2 to the Gesture Sensor DA Pin

1 Green Wire from the ProMicro 3 to the Gesture Sensor CL Pin

 

3.) Place the breadboard on the glove

 

1H_GG_DocuDir

Remove the back sticker of the breadboard and place on the center of the palm of your glove

 

How to Program your Galaxy Glove

1.) Open up Arduino (which you downloaded from the link above)
2.) Before Plugging in your ProMicro make sure to download Sparkfun’s board and build files. Here is a tutorial: https://learn.sparkfun.com/tutorials/pro-micro–fio-v3-hookup-guide

Windows Driver Installation

Step 1: Download the Driver

Before plugging your board in, get a head start by downloading the drivers. Check the GitHub Repository for the latest files. The same driver file works for both the Pro Micro and the Fio v3. The drivers for both the Fio and the Pro Micro are signed for Windows users. You can download them directly using the link below.

FIO AND PRO MICRO DRIVERS

Unzip that zip file, and don’t forget where you’ve left its contents. In that zip file, you should find an INF file, which contains all the information Windows needs to install the Pro Micro’s driver. This sparkfun.inf will be found in Arduino_Boards-master → sparkfun → avr → signed_driver.

Step 2: Plug in the Pro Micro / Fio v3

When you initially plug the board in, an “Installing device driver software” bubble notification should pop up in the lower-right corner of your taskbar. After the green dot circles the grey box a number of times, you’ll probably get a sad bubble like this:

Never fear! Windows just doesn’t know where to find our driver.

Note: Some users have experienced issues when plugging the Pro Micro into a USB 3.0 port. If you experience issues on USB 3.0 ports, try switching to use a USB 2.0 port.

Step 3: Open the Device Manager

From here, the most straightforward way to install the driver is through the Device Manager. To get to the Device Manager, click the Start button, then open the Control Panel. In the Control Panel, click System and Maintenance, and then open the Device Manager.

Alternatively, you can open the Run prompt (Windows key+R) and type ‘devmgmt.msc’ and click OK.

In the Device Manager, expand the ‘Other devices’ tree, where you should find a ‘USB IO Board’ with a yellow warning sign over its icon. Right-click the ‘USB IO Board’ and select Update Driver Software….

This should spawn an ‘Update Driver Software – USB IO Board’ window.

Step 4: Finding the Driver

In the first window that pops up, click ‘Browse my computer for driver software’. On the next window, click‘Browse…’ to search for the driver you just downloaded. It should be a folder named ‘Arduino_Boards-master’, in a subdirectory noted in step 1. After you’ve selected the ‘driver’ folder, click OK, then select Next.

Windows will attempt to do its driver install thing, but not before complaining about the driver being unsigned. It’s safe to select ‘Install this driver software anyway’ on the warning dialog.

After watching the progress bar beam by a few times, you should get a happy ‘Windows has successfully updated your driver software’ window. And the ‘Device Manager’ should have a new entry for the ‘SparkFun Pro Micro (COM ##)’ (or ‘SparkFun Fio V3 (COM##)’ if you have one of those) under the ‘Ports’ tree.

Take note of which COM port your Pro Micro was assigned. We’ll need it soon.

Installing the Arduino Addon

We’re still not completely ready for Arduino, but this is the final stretch. Before you can use the ProMicro in the Arduino IDE, you’ll need to install the board (.brd) files for the Fio/Pro Micro so the Arduino IDE will know how to communicate with your board.

Using the Board Manager

With the release of Arduino 1.6.4, adding third party boards to the Arduino IDE is easily achieved through the board manager. If you’re running an older version of Arduino (1.6.3 or earlier), we recommend upgrading now. As always, you can download the latest version of Arduino from arduino.cc.

To begin, you’ll need to point the Arduino IDE board manager to a custom URL. Open up Arduino, then go to the Preferences (File > Preferences). Then, towards the bottom of the window, paste this URL into the “Additional Board Manager URLs” text box:

COPY CODE

https://raw.githubusercontent.com/sparkfun/Arduino_Boards/master/IDE_Board_Manager/package_sparkfun_index.json

You can add multiple URLs by clicking the window icon, and pasting in one URL per line.

Click OK. Then open the Board Manager by clicking Tools, then hovering over the Board selection tab and clicking Board Manager.

Search for ‘sparkfun’ in the Board Manager. You should see the SparkFun AVR Boards package appear. Click install, wait a few moments, and all the .brd files you’ll need should be installed, indicated by the blue ‘Installed’ that is printed next to the package.

You should now be able to upload code to a number of SparkFun Arduino-compatible products, including the Fio and the Pro Micro.

Installing the .brd Files Manually

If you are using an older version of the Arduino IDE and do not have access to the Board Manager, then you’ll need to install the .brd files the old fashioned way.

To begin, download this zip folder, and unzip its contents into a ‘hardware’ directory within your Arduino sketchbook.

Note: These Arduino addon files only work with Arduino 1.5 and up. If you’re using an earlier version of Arduino, either update (and get some cool new features), or download the older version of the Addon.

Where’s your Arduino sketchbook? Well, by default, it should an ‘Arduino’ folder in your home directory, but to double check you can go to ‘File’ > ‘Preferences’ within Arduino and check the ‘Sketchbook location’ text box. Just make sure you close all Arduino windows once you’re done.

Once you’ve unzipped that folder into the ‘hardware’ folder within your Arduino sketchbook (you may actually have to create a hardware folder), your directory structure should look something like this:

The structure of this directory is critical – it should look something like “Arduino/hardware/[manufacturer]/[architecture]”, in this case [manufacturer] is “sparkfun”, and [architecture] is “avr.”

There’s a lot going on in that addon, but one of the most important files is ‘boards.txt’, which will add a few new entries to your ‘Tools > Board’ menu.

To double-check that the board definitions have been added to Arduino, open up Arduino, and check under the ‘Tools > Board’ menu. There should be some new entires for ‘SparkFun Pro Micro 8MHz/3.3V’, ‘SparkFun Pro Micro 16MHz/5V’, and other 32U4 boards.

Notice there are two options for Pro Micro – 8MHz and 16MHz. It’s very important that you select the Pro Micro option that matches your board’s voltage and speed. Don’t know which board you have? Check the bottom of the board, where you should find either a ‘5V’ or ‘3.3V’ box checked.

You should also see your Pro Micro’s COM port under the ‘Tools > Serial Port’ menu. Select it, and head over to theExample 1 page where we’ll upload our first piece of code.

Installing: Mac & Linux

If you’re using Mac or Linux, follow the steps below to get your Pro Micro (or Fio v3) ready to go on your computer. We’re not going to name names here, but installing the Pro Micro on Mac OS X and Linux is a lot easier than on other OS’s…

Following these directions is critical to getting your Pro Micro supported within your Arduino environment!

Board Installation

Using the Board Manager

With the release of Arduino 1.6.4, adding third party boards to the Arduino IDE is easily achieved through the board manager. If you’re running an older version of Arduino (1.6.3 or earlier), we recommend upgrading now. As always, you can download the latest version of Arduino from arduino.cc.

To begin, you’ll need to point the Arduino IDE board manager to a custom URL. Open up Arduino, then go to the Preferences (File > Preferences). Then, towards the bottom of the window, paste this URL into the “Additional Board Manager URLs” text box:

COPY CODE

https://raw.githubusercontent.com/sparkfun/Arduino_Boards/master/IDE_Board_Manager/package_sparkfun_index.json

You can add multiple URLs by clicking the window icon, and pasting in one URL per line.

Click OK. Then open the Board Manager by clicking Tools, then hovering over the Board selection tab and clicking Board Manager.

Search for ‘sparkfun’ in the Board Manager. You should see the SparkFun AVR Boards package appear. Click install, wait a few moments, and all the .brd files you’ll need should be installed, indicated by the blue ‘Installed’ that is printed next to the package.

You should now be able to upload code to a number of SparkFun Arduino-compatible products, including the Fio and the Pro Micro.

Installing the .brd Files Manually

If you are using an older version of the Arduino IDE and do not have access to the Board Manager, then you’ll need to install the .brd files the old fashioned way.

When you initially plug your Pro Micro into a Mac, it’ll pop up a “Keyboard Setup Assistant” window. This stems from the Pro Micro’s ability to emulate an HID USB device (e.g. keyboards and mice) – the Mac thinks your Pro Micro is a human input device (which it could be! but isn’t yet).

There’s nothing to configure in this window, so just click the big, red, ‘X’ to close it.

That’s all there is to it! The CDC (communication device class) portion of your Pro Micro (the part that handles USB to Serial conversion) should automatically install on your computer.

Installing the Arduino Addon

In order to use the Pro Micro or Fio v3 in your Arduino IDE, you need to add a few board definition files to it. That’s what we’ll do in this section. Begin by downloading the Pro Micro addon files.

Note: These Arduino addon files only work with Arduino 1.5 and up. If you’re using an earlier version of Arduino, either update (and get some cool new features), or download the older version of the Addon.

With that downloaded, follow these steps to enable the Pro Micro in your Arduino environment:

  1. The addon files are supplied in a zip folder, so you’ll need to extract the files within first.
  2. Find your Arduino sketchbook folder. If you don’t know where it is, you can locate your sketchbook by looking at the preferences dialog in your Arduino IDE.
  3. If there isn’t already one, create a folder in your sketchbook called ‘hardware’.
  4. Copy the ‘sparkfun’ folder that was unzipped in the first step into the ‘hardware’ folder.
    • Your directory structure should look something like “Arduino/hardware/sparkfun/avr.”
  5. Restart Arduino, and look under the Tools > Board menu. You should see a few new options, including ‘SparkFun Pro Micro 5V/16MHz’, ‘SparkFun Pro Micro 3.3V/8MHz’, and ‘’SparkFun Fio V3 3.3V/8MHz’.

If the boards are visible, select the option that matches your board. If you have a Pro Micro, make sure you select the correct operating speed and voltage! Then head over to the next page where we’ll upload our first sketch!

3.) Replace the Arduino code found below in the new file
with these files: Haptika_GalaxyGloveCompiled (code is also below)
3.) Put your glove on and make sure the usb is plugged into the glove and your computer
4.) Upload the Arduino code to your glove.
5.) After upload, quit Arduino and open up Processing (which you downloaded from the link above)
6.) Paste the Processing code below into the sketch and hit play!

 

You should now be the proud, empowered engineer, designer, and programmer of a Galaxy Glove!

Share your creation to Instagram, Facebook, Twitter, etc with 

#HaptikaEmpowered

///Haptika ***THE GALAXY GLOVE!!!***
/*

The Haptika Galaxy Glove is an electronic DIY project which
aims to represent a thereaputic DIY wearable platform to enable a sense of
embodiment and empowerment in special regards to those who are survivors
of trauma and abuse. Through the access, creation, remix, and use of the
Haptika platform, survivors have the potential to RE-member personal trauma
through play, embodiment, and empowerment.

This project in particular aims to mitigate the effects of abuse through specific
gesture and proximity as a means of haptic exploration. Intentional gesture,
mirrored in the premise of intentional making and completed action for assault
survivors, plays a vital role in enabling embodiment and empowerment in the user.
The expressive feedback is provided in an adaptable code sample that allows the user
to enact change in a visual environment. The example was inspired to provide a sense
of possibility, optimism, wonder, and playfulness.

Parts list:
ELECTRONICS:
2x Mini Breadboard
1x Sparkfun Pro Micro (https://www.sparkfun.com/products/12640)
1x Capacitive sense breakout board MPR121
1x Piezo
Copper Tape
Wires

DIY PARTS:
1x Glove
1x velcro or attaching material

Included in this code is Bildr’s code sample
*/

/****************************************************************
I2C_ZX_Demo.ino
XYZ Interactive ZX Sensor
Shawn Hymel @ SparkFun Electronics
May 6, 2015
https://github.com/sparkfun/SparkFun_ZX_Distance_and_Gesture_Sensor_Arduino_Library

Tests the ZX sensor’s ability to read ZX data over I2C. This demo
configures the ZX sensor and periodically polls for Z-axis and X-axis data.

Hardware Connections:

Arduino Pin ZX Sensor Board Function
—————————————
5V VCC Power
GND GND Ground
A4 DA I2C Data
A5 CL I2C Clock

Resources:
Include Wire.h and ZX_Sensor.h

Development environment specifics:
Written in Arduino 1.6.3
Tested with a SparkFun RedBoard

This code is beerware; if you see me (or any other SparkFun
employee) at the local, and you’ve found our code helpful, please
buy us a round!

Distributed as-is; no warranty is given.
****************************************************************/

#include <Wire.h>
#include <ZX_Sensor.h>

// Constants
const int ZX_ADDR = 0x10; // ZX Sensor I2C address

// Global Variables
ZX_Sensor zx_sensor = ZX_Sensor(ZX_ADDR);
uint8_t x_pos;
uint8_t z_pos;
GestureType gesture;
uint8_t gesture_speed;

void setup() {

uint8_t ver;

// Initialize Serial port
Serial.begin(9600);
Serial.println();
Serial.println(“———————————–“);
Serial.println(“SparkFun/GestureSense – I2C ZX Demo”);
Serial.println(“———————————–“);

// Initialize ZX Sensor (configure I2C and read model ID)
if ( zx_sensor.init() ) {
Serial.println(“ZX Sensor initialization complete”);
} else {
Serial.println(“Something went wrong during ZX Sensor init!”);
}

// Read the model version number and ensure the library will work
ver = zx_sensor.getModelVersion();
if ( ver == ZX_ERROR ) {
Serial.println(“Error reading model version number”);
} else {
Serial.print(“Model version: “);
Serial.println(ver);
}
if ( ver != ZX_MODEL_VER ) {
Serial.print(“Model version needs to be “);
Serial.print(ZX_MODEL_VER);
Serial.print(” to work with this library. Stopping.”);
while(1);
}

// Read the register map version and ensure the library will work
ver = zx_sensor.getRegMapVersion();
if ( ver == ZX_ERROR ) {
Serial.println(“Error reading register map version number”);
} else {
Serial.print(“Register Map Version: “);
Serial.println(ver);
}
if ( ver != ZX_REG_MAP_VER ) {
Serial.print(“Register map version needs to be “);
Serial.print(ZX_REG_MAP_VER);
Serial.print(” to work with this library. Stopping.”);
while(1);
}
}

void loop() {
/* /////IS NOT PRINTING GESTURE
if ( zx_sensor.gestureAvailable() ) {
gesture = zx_sensor.readGesture();
gesture_speed = zx_sensor.readGestureSpeed();
switch ( gesture ) {
case NO_GESTURE:
Serial.println(“No Gesture”);
break;
case RIGHT_SWIPE:
Serial.print(“Right Swipe. Speed: “);
Serial.println(gesture_speed, DEC);
break;
case LEFT_SWIPE:
Serial.print(“Left Swipe. Speed: “);
Serial.println(gesture_speed, DEC);
break;
case UP_SWIPE:
Serial.print(“Up Swipe. Speed: “);
Serial.println(gesture_speed, DEC);
break;
default:
break;
}
} */
// If there is position data available, read and print it
if ( zx_sensor.positionAvailable() ) {
x_pos = zx_sensor.readX();
if ( x_pos != ZX_ERROR ) {
//Serial.print(“X: “);
Serial.print(x_pos);
Serial.print(“,”);
}

z_pos = zx_sensor.readZ();
if ( z_pos != ZX_ERROR ) {
// Serial.print(” Z: “);
Serial.println(z_pos);
}
}

}

Download this file: Haptika_ExploreYourOwnGalaxiesv_01 or copy and paste this code into a new processing sketch:

// // // *** Sketch by Zoe Doubleday // // //

//sketch notes:

//expand array list of stars
//generally, proximity equals more stars, more connectedness of particle system
//and gesture (like a secret handshake) creates an event
//such as colorizing and adding more movement to the galaxy

import processing.serial.*;
// The serial port:
Serial myPort;

Particle particle;
Particle particle2;
Particle particle3;
color color1;
color color2;
ArrayList stars;
float starValue;
float particleValue;
float webValue;
void setup(){
noCursor();
frameRate(10);
size(1280,720, P3D);
smooth(8); //super anti-aliasing!

// List all the available serial ports:
printArray(Serial.list());
// Open the port you are using at the rate you want:
myPort = new Serial(this, Serial.list()[2], 9600);
// don’t generate a serialEvent() unless you get a newline character:
myPort.bufferUntil(‘\n’);

particle = new Particle(width*0.27, height*0.47, color1, color2); //the (run) width and (rise) height of the entire system and color

background(0);
}

void draw(){

fill(0,50); //slightly transparent so that it gives the particle system a slightly blurred motion
noStroke();
rect(0,0,width,height); //this keeps it from layering on top of itself but it slightly transparent so that it gives the particle system a slightly blurred motion

stars = new ArrayList();
for(int i = 1; i <= starValue; i++){
stars.add(new star());
}

particle.display(); //display the Particle Class!
for(int i = 0; i <= stars.size()-1; i++){
star starUse = (star) stars.get(i);
starUse.display();
}
}

void serialEvent(Serial myPort){
//get the ASCII string:
String inString = myPort.readStringUntil(‘\n’);

if(inString != null){
//trim off whitespace:
inString = trim(inString);
//split the string on the commas and convert
//resulting substrings in an integer array:
float[] values = float(split(inString, “,”));
//put numbers in value variables 0 and 1
if (values.length >=2){
//map them to a specific range
//this is for Z (add starValue above)
starValue = map(values[1], 250, 0, 0, 600);
webValue=map(values[1], 250, 0, .03, .09);
//this is for X and add particleValue above…
particleValue = map(values[0], 230, 0, 255, 0);
}
}
println(webValue);
}
//////The Main Particle Class //////////
class Particle {
///the array
Parvect[] partsys;
///Listing all the variables
float distBase; //distribution base – how connected the particles are; reducing the variable will reduce the connectivity
float webVar; //more or less webby (keep between .7 and 1.1)
float lineMax; //line thickness
float run; // width – determined in setup
float rise; // height – – determined in setup

PVector temp1; //temporary equations that allow for generation while it runs through the code
PVector temp2; // ^

float tempDist; //temporary equations that allow for generation while it runs through the code
float strokeVar;
float varColor;
color color1; //determined in void display()
color color2; //determined in void display()
color colorStroke;

//determined below to keep it all constrained in an even manner
float minX;
float minY;
float maxX;
float maxY;

////Saying what is going to be going on in the Particle class – i.e. the constructors
Particle(float run, float rise, color color1, color color2){

run=run;
rise=rise;
color1=color1;
color2=color2;

distBase=(run + rise); //connectivity & base of distribution = run and rise, changing these values will change the connections
//webVar = .03; //distribution of webbing…adding more makes it webby and slow, less makes it more sparse
lineMax = 60; //how thick the lines are

//this keeps it constrained
minX = (width-run)*0.5;
minY = (height-rise)*0.5;
maxX = (width+run)*0.5;
maxY = (height+rise)*0.5;

partsys= new Parvect [150]; // 350 particles array for pvector

for(int i = 0; i < partsys.length; i++){
partsys[i] = new Parvect(run,rise); //making the arrrrraaaayyyy! index of [0] = run; [1] = rise
}
}

void display(){

strokeWeight(1); //the weight of the stroke
smooth(8); //8x anti aliasing
webVar = webValue; //distribution of webbing…adding more makes it webby and slow, less makes it more sparse
//color3 = color(random(240,255), random(80,100), 0);
//color4 = color(random(60,80),20,random(200,225));
//color1 = color(random(250,255), random(200,220), 255);
//color2 = color(random(200,250),220,random(205,225));
color1 = color(random(particleValue,255), random(100,particleValue), particleValue);
color2 = color(random(particleValue,255),particleValue,random(particleValue,225));

for(int i = 0; i < partsys.length; i++){
partsys[i].update(); //updating from ParVect
}
///NESTED LOOP! For temporary equations before running through the code and then putting the PVector business in there
for (int i = 0; i<partsys.length; i++){
for (int j = 0; j<partsys.length; j++){
temp1 = partsys[i].getPosition();
temp2 = partsys[j].getPosition();
tempDist = PVector.dist(temp1, temp2); //measuring the distance between these two variables here

if (tempDist < distBase*webVar*1.2){ //connection and webbiness
varColor = map(temp1.x, minX, maxX, 0., 1.); //mapping it between 0 – 1 = this is the variable for how the color is mapped across the particle system
strokeVar = map(tempDist, 300, distBase*webVar, 300, lineMax); //determines the thickness of the lines – with bigger values in the map, it makes the map less crowded
//lerpColor(c1, c2, amt)
colorStroke = lerpColor(color1, color2, varColor); //lerpColor!!! Creates a color shift: (color1, color2, and the shift amount between)
//stroke (red var, green var, blue var, alpha)
stroke(red(colorStroke), green(colorStroke), blue(colorStroke), strokeVar); //this is an easier way to store the color values from the lerpColor so that it doesnt slow down the computer
line(temp1.x+10, temp1.y+10, temp2.x+7, temp2.y+7); //THE ACTUAL LINE!!!! YAY!!! This comes from the PVector stuff below and the “temp” allows it to run through and return to here! – The math in there creates an uneven double vision effect

}
}
}
}

}
////Bring on the PVector class! /////
class Parvect {
PVector position; //PVector for where it moves
PVector velocity; //PVector for how it moves
float run; //width
float rise; //height
float minX; //min width size
float minY; //min height size
float maxX; //max width size
float maxY; //max height size
float maxVel; //speed of velocity
float rad; //distribution of webbiness and how it connected
float radBase; //width + height
float radFac; //how closely it will remain connected

Parvect(float run, float rise){
this.run = run;
this.rise=rise;
maxVel = .80; //for velocity to use in PVector (the higher it is, the faster it goes) — Can be .90 or 1.0(slightly faster)
radFac = .5; //how close it all stays connected to each other! — keep at .5 or else there are straglers and DISSENSION!
radBase = (run + rise); //like dist base – level of connectivity and how it is connected
rad = radBase*radFac; //the distribution of webbiness x connectivity – this equations makes it go outward in an even way

//this keeps it constrained and evenly distributed
minX = (width-run)*0.5;
minY = (height-rise)*0.5;
maxX = (width+run)*0.5;
maxY = (height+rise)*0.5;

/////POSITION VECTOR – how it expands and contracts/////
position = new PVector(random(minX,maxX), random(minY,maxY)); //PVector(x,y) — generative vector based on X and Y values
if(dist(position.x, position.y, width/2, height/2) > rad) { //float distance calculated between the two points of the vector
//if the distance between the two ^ points, it normalizes to make the position as 1 (that is why it bounces back)
position.normalize();
position.mult(rad); //multiplying the Position Vector by rad which means it expands evenly
}
/////VELOCITY VECTOR – speed of movement /////
velocity = new PVector (random(-maxVel, maxVel), random(-maxVel, maxVel)); //this keeps all the movement equal but still going outward
}

////UPDATE FUNCTION – for how to treat the position and velocity when it hits the edge – for bounce back////
void update(){
if (dist(position.x, position.y, width*.5, height*.5) > rad) { //if it gets to half of height and half of width, bounce it back
velocity.mult(-1); //multiplies the velocity by -1 which BOUNCES IT BACK!
}
position.add(velocity); //addition of velocity to position – without this, nothing moves
}
//returns the position of the vectors to the displays above!
PVector getPosition(){
return position;
}
}
class star {
int xPos, yPos, starSize;
float flickerRate, light;
boolean rise;
star(){
flickerRate = random(0,1);
starSize = int(random(1,4));
xPos = int(random(width));
yPos = int(random(height));
light = random(10,245);
rise = true;

}
void display(){
if(light >= 245){
rise = false;
}
if(light <= 10){
flickerRate = random(2,5);
starSize = int(random(2,5));
rise = true;
xPos = int(random(width));
yPos = int(random(height));
}
if(rise == true){
light += flickerRate;
}
if(rise == false){
light -= flickerRate;
}
fill(light);
rect(xPos, yPos,starSize,starSize);

}
}

Open up one of the .pde files and all the other files will embed as needed.

 

If you run into any problems, don’t hesitate to contact me