All posts by jessyjogomez

Final Project: Uglydoll Maker

Using a controller with 3 potentiometers – one to select the color, tab, and attribute – make your very own Uglydoll! This project was made using Arduino and Processing.

fbguj

controller

// Jessy Jo Gomez
// uglydoll maker (final)

float currentTab = 1;
float currentBox = 0;
float currentColor = 0;
float bodyType = 0;
float eyesType = 0;
float noseType = 2;
float mouthType = 0;

int bodyX = 1;
int bodyY = 1;
int eyesX = 1;
int eyesY = 1;
int noseX = 1;
int noseY = 1;
int mouthX = 1;
int mouthY = 1;

int selectColor = 0;
int selectTab = 0;
int selectAttribute = 0;

PImage template;
PImage tabBody;
PImage tabEyes;
PImage tabNose;
PImage tabMouth;
PImage currentBody;
PImage currentEyes;
PImage currentNose;
PImage currentMouth;

// TODO 1: copy these (3 lines):
import processing.serial.*;
Serial port; // The serial port object
boolean sending = false;

void setup() {

// TODO 2: copy these (2 lines):
// Using the first available port (might be different on your computer)
port = new Serial(this, Serial.list()[0], 9600);

size (550, 400);

template = loadImage(“template.png”);
currentBody = loadImage(“spacer.gif”);
currentEyes = loadImage(“spacer.gif”);
currentNose = loadImage(“spacer.gif”);
currentMouth = loadImage(“spacer.gif”);
tabBody = loadImage(“tabBody.png”);
tabEyes = loadImage(“tabEyes.png”);
tabNose = loadImage(“tabNose.png”);
tabMouth = loadImage(“tabMouth.png”);
}

void draw() {

image(template, 0, 0);
image(currentBody, bodyX, bodyY);
image(currentEyes, eyesX, eyesY);
image(currentNose, noseX, noseY);
image(currentMouth, mouthX, mouthY);

// tab positions

if ( selectTab > 0 && selectTab < 63 ) {
currentTab = 1;
}
if ( selectTab > 63 && selectTab < 126 ) {
currentTab = 2;
}
if ( selectTab > 126 && selectTab < 189 ) {
currentTab = 3;
}
if ( selectTab > 189 && selectTab < 255 ) {
currentTab = 4;
}

// color positions

if ( selectColor > 0 && selectColor < 31 ) {
currentColor = 0;
}
if ( selectColor > 31 && selectColor < 62 ) {
currentColor = 1;
}
if ( selectColor > 62 && selectColor < 93 ) {
currentColor = 2;
}
if ( selectColor > 93 && selectColor < 124 ) {
currentColor = 3;
}
if ( selectColor > 124 && selectColor < 155 ) {
currentColor = 4;
}
if ( selectColor > 155 && selectColor < 186 ) {
currentColor = 5;
}
if ( selectColor > 186 && selectColor < 217 ) {
currentColor = 6;
}
if ( selectColor > 217 && selectColor < 255 ) {
currentColor = 7;
}

// body tab

if ( currentTab == 1 ) {
image(tabBody, 288, -1);
if ( selectAttribute > 0 && selectAttribute < 42 ) {
currentBody = loadImage(“baboGrey.png”);
bodyType = 1;
bodyX = 205;
bodyY = 213;
}
if ( selectAttribute > 42 && selectAttribute < 84 ) {
currentBody = loadImage(“plunkoGrey.png”);
bodyType = 2;
bodyX = 206;
bodyY = 174;
}
if ( selectAttribute > 84 && selectAttribute < 126 ) {
currentBody = loadImage(“icebatGrey.png”);
bodyType = 3;
bodyX = 182;
bodyY = 189;
}
if ( selectAttribute > 126 && selectAttribute < 168 ) {
currentBody = loadImage(“uglywormGrey.png”);
bodyType = 4;
bodyX = 208;
bodyY = 218;
}
if ( selectAttribute > 168 && selectAttribute < 210 ) {
currentBody = loadImage(“wedgeheadGrey.png”);
bodyType = 5;
bodyX = 218;
bodyY = 218;
}
if ( selectAttribute > 210 && selectAttribute < 255 ) {
currentBody = loadImage(“feebeeGrey.png”);
bodyType = 6;
bodyX = 214;
bodyY = 186;
}
}

// babo’s colors

if ( bodyType == 1 ) {
if ( currentColor == 0 ) {
currentBody = loadImage(“baboGrey.png”);
}
if ( currentColor == 1 ) {
currentBody = loadImage(“baboRed.png”);
}
if ( currentColor == 2 ) {
currentBody = loadImage(“baboOrange.png”);
}
if ( currentColor == 3 ) {
currentBody = loadImage(“baboYellow.png”);
}
if ( currentColor == 4 ) {
currentBody = loadImage(“baboGreen.png”);
}
if ( currentColor == 5 ) {
currentBody = loadImage(“baboBlue.png”);
}
if ( currentColor == 6 ) {
currentBody = loadImage(“baboPurple.png”);
}
if ( currentColor == 7 ) {
currentBody = loadImage(“baboBlack.png”);
}
}

// plunko’s colors

if ( bodyType == 2 ) {
if ( currentColor == 0 ) {
currentBody = loadImage(“plunkoGrey.png”);
}
if ( currentColor == 1 ) {
currentBody = loadImage(“plunkoRed.png”);
}
if ( currentColor == 2 ) {
currentBody = loadImage(“plunkoOrange.png”);
}
if ( currentColor == 3 ) {
currentBody = loadImage(“plunkoYellow.png”);
}
if ( currentColor == 4 ) {
currentBody = loadImage(“plunkoGreen.png”);
}
if ( currentColor == 5 ) {
currentBody = loadImage(“plunkoBlue.png”);
}
if ( currentColor == 6 ) {
currentBody = loadImage(“plunkoPurple.png”);
}
if ( currentColor == 7 ) {
currentBody = loadImage(“plunkoBlack.png”);
}
}

// icebat’s colors

if ( bodyType == 3 ) {
if ( currentColor == 0 ) {
currentBody = loadImage(“icebatGrey.png”);
}
if ( currentColor == 1 ) {
currentBody = loadImage(“icebatRed.png”);
}
if ( currentColor == 2 ) {
currentBody = loadImage(“icebatOrange.png”);
}
if ( currentColor == 3 ) {
currentBody = loadImage(“icebatYellow.png”);
}
if ( currentColor == 4 ) {
currentBody = loadImage(“icebatGreen.png”);
}
if ( currentColor == 5 ) {
currentBody = loadImage(“icebatBlue.png”);
}
if ( currentColor == 6 ) {
currentBody = loadImage(“icebatPurple.png”);
}
if ( currentColor == 7 ) {
currentBody = loadImage(“icebatBlack.png”);
}
}

// uglyworm’s colors

if ( bodyType == 4 ) {
if ( currentColor == 0 ) {
currentBody = loadImage(“uglywormGrey.png”);
}
if ( currentColor == 1 ) {
currentBody = loadImage(“uglywormRed.png”);
}
if ( currentColor == 2 ) {
currentBody = loadImage(“uglywormOrange.png”);
}
if ( currentColor == 3 ) {
currentBody = loadImage(“uglywormYellow.png”);
}
if ( currentColor == 4 ) {
currentBody = loadImage(“uglywormGreen.png”);
}
if ( currentColor == 5 ) {
currentBody = loadImage(“uglywormBlue.png”);
}
if ( currentColor == 6 ) {
currentBody = loadImage(“uglywormPurple.png”);
}
if ( currentColor == 7 ) {
currentBody = loadImage(“uglywormBlack.png”);
}
}

// wedgehead’s colors

if ( bodyType == 5 ) {
if ( currentColor == 0 ) {
currentBody = loadImage(“wedgeheadGrey.png”);
}
if ( currentColor == 1 ) {
currentBody = loadImage(“wedgeheadRed.png”);
}
if ( currentColor == 2 ) {
currentBody = loadImage(“wedgeheadOrange.png”);
}
if ( currentColor == 3 ) {
currentBody = loadImage(“wedgeheadYellow.png”);
}
if ( currentColor == 4 ) {
currentBody = loadImage(“wedgeheadGreen.png”);
}
if ( currentColor == 5 ) {
currentBody = loadImage(“wedgeheadBlue.png”);
}
if ( currentColor == 6 ) {
currentBody = loadImage(“wedgeheadPurple.png”);
}
if ( currentColor == 7 ) {
currentBody = loadImage(“wedgeheadBlack.png”);
}
}

// feebee’s colors

if ( bodyType == 6 ) {
if ( currentColor == 0 ) {
currentBody = loadImage(“feebeeGrey.png”);
}
if ( currentColor == 1 ) {
currentBody = loadImage(“feebeeRed.png”);
}
if ( currentColor == 2 ) {
currentBody = loadImage(“feebeeOrange.png”);
}
if ( currentColor == 3 ) {
currentBody = loadImage(“feebeeYellow.png”);
}
if ( currentColor == 4 ) {
currentBody = loadImage(“feebeeGreen.png”);
}
if ( currentColor == 5 ) {
currentBody = loadImage(“feebeeBlue.png”);
}
if ( currentColor == 6 ) {
currentBody = loadImage(“feebeePurple.png”);
}
if ( currentColor == 7 ) {
currentBody = loadImage(“feebeeBlack.png”);
}
}

// eyes tab

if ( currentTab == 2 ) {
image(tabEyes, 288, -1);
if ( selectAttribute > 0 && selectAttribute < 42 ) {
currentEyes = loadImage(“eyes1.png”);
eyesType = 1;
}
if ( selectAttribute > 42 && selectAttribute < 84 ) {
currentEyes = loadImage(“eyes2.png”);
eyesType = 2;
}
if ( selectAttribute > 84 && selectAttribute < 126 ) {
currentEyes = loadImage(“eyes3.png”);
eyesType = 3;
}
if ( selectAttribute > 126 && selectAttribute < 168 ) {
currentEyes = loadImage(“eyes4.png”);
eyesType = 4;
}
if ( selectAttribute > 168 && selectAttribute < 210 ) {
currentEyes = loadImage(“eyes5.png”);
eyesType = 5;
}
if ( selectAttribute > 210 && selectAttribute < 255 ) {
currentEyes = loadImage(“eyes6.png”);
eyesType = 6;
}
}

if ( bodyType == 0 ) {
currentEyes = loadImage(“spacer.gif”);
}

// babo’s eyes

if ( bodyType == 1 ) {
if ( eyesType == 1 || eyesType == 4 || eyesType == 6 ) {
eyesX = 243;
eyesY = 233;
}
if ( eyesType == 2 || eyesType == 5 ) {
eyesX = 263;
eyesY = 233;
}
if ( eyesType == 3 ) {
eyesX = 245;
eyesY = 226;
}
}

// plunko’s eyes

if ( bodyType == 2 ) {
if ( eyesType == 1 || eyesType == 4 || eyesType == 6 ) {
eyesX = 250;
eyesY = 227;
}
if ( eyesType == 2 || eyesType == 5 ) {
eyesX = 270;
eyesY = 227;
}
if ( eyesType == 3 ) {
eyesX = 252;
eyesY = 220;
}
}

// icebat’s eyes

if ( bodyType == 3 ) {
if ( eyesType == 1 || eyesType == 4 || eyesType == 6 ) {
eyesX = 243;
eyesY = 233;
}
if ( eyesType == 2 || eyesType == 5 ) {
eyesX = 263;
eyesY = 233;
}
if ( eyesType == 3 ) {
eyesX = 245;
eyesY = 226;
}
}

// uglyworm’s eyes

if ( bodyType == 4 ) {
if ( eyesType == 1 || eyesType == 4 || eyesType == 6 ) {
eyesX = 229;
eyesY = 233;
}
if ( eyesType == 2 || eyesType == 5 ) {
eyesX = 249;
eyesY = 233;
}
if ( eyesType == 3 ) {
eyesX = 231;
eyesY = 226;
}
}

// wedgehead’s eyes

if ( bodyType == 5 ) {
if ( eyesType == 1 || eyesType == 4 || eyesType == 6 ) {
eyesX = 243;
eyesY = 230;
}
if ( eyesType == 2 || eyesType == 5 ) {
eyesX = 263;
eyesY = 230;
}
if ( eyesType == 3 ) {
eyesX = 245;
eyesY = 223;
}
}

// feebee’s eyes

if ( bodyType == 6 ) {
if ( eyesType == 1 || eyesType == 4 || eyesType == 6 ) {
eyesX = 249;
eyesY = 200;
}
if ( eyesType == 2 || eyesType == 5 ) {
eyesX = 269;
eyesY = 200;
}
if ( eyesType == 3 ) {
eyesX = 251;
eyesY = 193;
}
}

// nose tab

if ( currentTab == 3 ) {
image(tabNose, 288, -1);
if ( selectAttribute > 0 && selectAttribute < 127 ) {
currentNose = loadImage(“nose1.png”);
noseType = 1;
}
if ( selectAttribute > 127 && selectAttribute < 255 ) {
currentNose = loadImage(“spacer.gif”);
noseType = 2;
}
}

if ( bodyType == 0 ) {
currentNose = loadImage(“spacer.gif”);
}

// nose positions

if ( bodyType == 1 && noseType == 1 || bodyType == 1 && noseType == 2 ) {
noseX = 258;
noseY = 251;
}
if ( bodyType == 2 && noseType == 1 || bodyType == 2 && noseType == 2 ) {
noseX = 265;
noseY = 245;
}
if ( bodyType == 3 && noseType == 1 || bodyType == 3 && noseType == 2 ) {
noseX = 258;
noseY = 251;
}
if ( bodyType == 4 && noseType == 1 || bodyType == 4 && noseType == 2 ) {
noseX = 244;
noseY = 251;
}
if ( bodyType == 5 && noseType == 1 || bodyType == 5 && noseType == 2 ) {
noseX = 258;
noseY = 248;
}
if ( bodyType == 6 && noseType == 1 || bodyType == 6 && noseType == 2 ) {
noseX = 264;
noseY = 218;
}

// mouth tab

if ( currentTab == 4 ) {
image(tabMouth, 288, -1);
if ( selectAttribute > 0 && selectAttribute < 42 ) {
currentMouth = loadImage(“mouth1.png”);
mouthType = 1;
}
if ( selectAttribute > 42 && selectAttribute < 84 ) {
currentMouth = loadImage(“mouth2.png”);
mouthType = 2;
}
if ( selectAttribute > 84 && selectAttribute < 126 ) {
currentMouth = loadImage(“mouth3.png”);
mouthType = 3;
}
if ( selectAttribute > 126 && selectAttribute < 168 ) {
currentMouth = loadImage(“mouth4.png”);
mouthType = 4;
}
if ( selectAttribute > 168 && selectAttribute < 210 ) {
currentMouth = loadImage(“mouth5.png”);
mouthType = 5;
}
if ( selectAttribute > 210 && selectAttribute < 255 ) {
currentMouth = loadImage(“mouth6.png”);
mouthType = 6;
}
}

if ( bodyType == 0 ) {
currentMouth = loadImage(“spacer.gif”);
}

// babo’s mouth

if ( bodyType == 1 && noseType == 2 && mouthType == 1 ) {
mouthX = 240;
mouthY = 256;
}
if ( bodyType == 1 && noseType == 1 && mouthType == 1 ) {
mouthX = 240;
mouthY = 265;
}
if ( bodyType == 1 && noseType == 2 && mouthType == 2 ) {
mouthX = 240;
mouthY = 256;
}
if ( bodyType == 1 && noseType == 1 && mouthType == 2 ) {
mouthX = 240;
mouthY = 265;
}
if ( bodyType == 1 && noseType == 2 && mouthType == 3 ) {
mouthX = 240;
mouthY = 256;
}
if ( bodyType == 1 && noseType == 1 && mouthType == 3 ) {
mouthX = 240;
mouthY = 265;
}
if ( bodyType == 1 && noseType == 2 && mouthType == 4 ) {
mouthX = 240;
mouthY = 256;
}
if ( bodyType == 1 && noseType == 1 && mouthType == 4 ) {
mouthX = 240;
mouthY = 265;
}
if ( bodyType == 1 && noseType == 2 && mouthType == 5 ) {
mouthX = 240;
mouthY = 256;
}
if ( bodyType == 1 && noseType == 1 && mouthType == 5 ) {
mouthX = 240;
mouthY = 265;
}
if ( bodyType == 1 && noseType == 2 && mouthType == 6 ) {
mouthX = 240;
mouthY = 256;
}
if ( bodyType == 1 && noseType == 1 && mouthType == 6 ) {
mouthX = 240;
mouthY = 265;
}

// plunko’s mouth

if ( bodyType == 2 && noseType == 2 && mouthType == 1 ) {
mouthX = 247;
mouthY = 250;
}
if ( bodyType == 2 && noseType == 1 && mouthType == 1 ) {
mouthX = 247;
mouthY = 259;
}
if ( bodyType == 2 && noseType == 2 && mouthType == 2 ) {
mouthX = 247;
mouthY = 250;
}
if ( bodyType == 2 && noseType == 1 && mouthType == 2 ) {
mouthX = 247;
mouthY = 259;
}
if ( bodyType == 2 && noseType == 2 && mouthType == 3 ) {
mouthX = 247;
mouthY = 250;
}
if ( bodyType == 2 && noseType == 1 && mouthType == 3 ) {
mouthX = 247;
mouthY = 259;
}
if ( bodyType == 2 && noseType == 2 && mouthType == 4 ) {
mouthX = 247;
mouthY = 250;
}
if ( bodyType == 2 && noseType == 1 && mouthType == 4 ) {
mouthX = 247;
mouthY = 259;
}
if ( bodyType == 2 && noseType == 2 && mouthType == 5 ) {
mouthX = 247;
mouthY = 250;
}
if ( bodyType == 2 && noseType == 1 && mouthType == 5 ) {
mouthX = 247;
mouthY = 259;
}
if ( bodyType == 2 && noseType == 2 && mouthType == 6 ) {
mouthX = 247;
mouthY = 250;
}
if ( bodyType == 2 && noseType == 1 && mouthType == 6 ) {
mouthX = 247;
mouthY = 259;
}

// icebat’s mouth

if ( bodyType == 3 && noseType == 2 && mouthType == 1 ) {
mouthX = 240;
mouthY = 256;
}
if ( bodyType == 3 && noseType == 1 && mouthType == 1 ) {
mouthX = 240;
mouthY = 265;
}
if ( bodyType == 3 && noseType == 2 && mouthType == 2 ) {
mouthX = 240;
mouthY = 256;
}
if ( bodyType == 3 && noseType == 1 && mouthType == 2 ) {
mouthX = 240;
mouthY = 265;
}
if ( bodyType == 3 && noseType == 2 && mouthType == 3 ) {
mouthX = 240;
mouthY = 256;
}
if ( bodyType == 3 && noseType == 1 && mouthType == 3 ) {
mouthX = 240;
mouthY = 265;
}
if ( bodyType == 3 && noseType == 2 && mouthType == 4 ) {
mouthX = 240;
mouthY = 256;
}
if ( bodyType == 3 && noseType == 1 && mouthType == 4 ) {
mouthX = 240;
mouthY = 265;
}
if ( bodyType == 3 && noseType == 2 && mouthType == 5 ) {
mouthX = 240;
mouthY = 256;
}
if ( bodyType == 3 && noseType == 1 && mouthType == 5 ) {
mouthX = 240;
mouthY = 265;
}
if ( bodyType == 3 && noseType == 2 && mouthType == 6 ) {
mouthX = 240;
mouthY = 256;
}
if ( bodyType == 3 && noseType == 1 && mouthType == 6 ) {
mouthX = 240;
mouthY = 265;
}

// uglyworm’s mouth

if ( bodyType == 4 && noseType == 2 && mouthType == 1 ) {
mouthX = 226;
mouthY = 256;
}
if ( bodyType == 4 && noseType == 1 && mouthType == 1 ) {
mouthX = 226;
mouthY = 265;
}
if ( bodyType == 4 && noseType == 2 && mouthType == 2 ) {
mouthX = 226;
mouthY = 256;
}
if ( bodyType == 4 && noseType == 1 && mouthType == 2 ) {
mouthX = 226;
mouthY = 265;
}
if ( bodyType == 4 && noseType == 2 && mouthType == 3 ) {
mouthX = 226;
mouthY = 256;
}
if ( bodyType == 4 && noseType == 1 && mouthType == 3 ) {
mouthX = 226;
mouthY = 265;
}
if ( bodyType == 4 && noseType == 2 && mouthType == 4 ) {
mouthX = 226;
mouthY = 256;
}
if ( bodyType == 4 && noseType == 1 && mouthType == 4 ) {
mouthX = 226;
mouthY = 265;
}
if ( bodyType == 4 && noseType == 2 && mouthType == 5 ) {
mouthX = 226;
mouthY = 256;
}
if ( bodyType == 4 && noseType == 1 && mouthType == 5 ) {
mouthX = 226;
mouthY = 265;
}
if ( bodyType == 4 && noseType == 2 && mouthType == 6 ) {
mouthX = 226;
mouthY = 256;
}
if ( bodyType == 4 && noseType == 1 && mouthType == 6 ) {
mouthX = 226;
mouthY = 265;
}

// wedgehead’s mouth

if ( bodyType == 5 && noseType == 2 && mouthType == 1 ) {
mouthX = 240;
mouthY = 256;
}
if ( bodyType == 5 && noseType == 1 && mouthType == 1 ) {
mouthX = 240;
mouthY = 262;
}
if ( bodyType == 5 && noseType == 2 && mouthType == 2 ) {
mouthX = 240;
mouthY = 256;
}
if ( bodyType == 5 && noseType == 1 && mouthType == 2 ) {
mouthX = 240;
mouthY = 262;
}
if ( bodyType == 5 && noseType == 2 && mouthType == 3 ) {
mouthX = 240;
mouthY = 256;
}
if ( bodyType == 5 && noseType == 1 && mouthType == 3 ) {
mouthX = 240;
mouthY = 262;
}
if ( bodyType == 5 && noseType == 2 && mouthType == 4 ) {
mouthX = 240;
mouthY = 256;
}
if ( bodyType == 5 && noseType == 1 && mouthType == 4 ) {
mouthX = 240;
mouthY = 262;
}
if ( bodyType == 5 && noseType == 2 && mouthType == 5 ) {
mouthX = 240;
mouthY = 256;
}
if ( bodyType == 5 && noseType == 1 && mouthType == 5 ) {
mouthX = 240;
mouthY = 262;
}
if ( bodyType == 5 && noseType == 2 && mouthType == 6 ) {
mouthX = 240;
mouthY = 256;
}
if ( bodyType == 5 && noseType == 1 && mouthType == 6 ) {
mouthX = 240;
mouthY = 262;
}

// feebee’s mouth

if ( bodyType == 6 && noseType == 2 && mouthType == 1 ) {
mouthX = 243;
mouthY = 223;
}
if ( bodyType == 6 && noseType == 1 && mouthType == 1 ) {
mouthX = 243;
mouthY = 232;
}
if ( bodyType == 6 && noseType == 2 && mouthType == 2 ) {
mouthX = 243;
mouthY = 223;
}
if ( bodyType == 6 && noseType == 1 && mouthType == 2 ) {
mouthX = 243;
mouthY = 232;
}
if ( bodyType == 6 && noseType == 2 && mouthType == 3 ) {
mouthX = 243;
mouthY = 223;
}
if ( bodyType == 6 && noseType == 1 && mouthType == 3 ) {
mouthX = 243;
mouthY = 232;
}
if ( bodyType == 6 && noseType == 2 && mouthType == 4 ) {
mouthX = 243;
mouthY = 223;
}
if ( bodyType == 6 && noseType == 1 && mouthType == 4 ) {
mouthX = 243;
mouthY = 232;
}
if ( bodyType == 6 && noseType == 2 && mouthType == 5 ) {
mouthX = 243;
mouthY = 223;
}
if ( bodyType == 6 && noseType == 1 && mouthType == 5 ) {
mouthX = 243;
mouthY = 232;
}
if ( bodyType == 6 && noseType == 2 && mouthType == 6 ) {
mouthX = 243;
mouthY = 223;
}
if ( bodyType == 6 && noseType == 1 && mouthType == 6 ) {
mouthX = 243;
mouthY = 232;
}

// TODO 3: add this if statement (4 lines) to the end of your draw() function
// until we start sending, ask for values
if ( !sending ) {
port.write(65); // arbitrary character (the letter A)
}
}

// TODO 4: copy this whole function into your code (at the end)
// Called whenever there is something available to read
void serialEvent(Serial port) {

sending = true;

// Data from the Serial port is read in serialEvent() using the readStringUntil()
// function with * as the end character.
String input = port.readStringUntil(‘*’);

if (input != null) {
// Print message received
println( “Receiving:” + input);

// The data is split into an array of Strings with a comma or
// asterisk as a delimiter and converted into an array of integers.
int[] vals = int(splitTokens(input, “,*”));

// the num variable will hold the value we’ve read from the serial connection
selectColor = vals[0];

// TODO 5: If you are using more than one sensor, set the other values here. For example:
selectTab = vals[1];
selectAttribute = vals[2];
// etc.
// And just make sure these variables are declared up top (eg, “int otherNum;”)
}

// When finished ask for values again
port.write(65);
}

//Jessy Jo Gomez
//”communication”

int firstSensor = 0; // first analog sensor
int secondSensor = 0; // second analog sensor
int thirdSensor = 0; // third analog sensor
int inByte = 0; // incoming serial byte

void setup()
{
// start serial port at 9600 bps:
Serial.begin(9600);
}

void loop()
{
// if we get a valid byte, read analog ins:
if (Serial.available() > 0) {
// get incoming byte:
inByte = Serial.read();
// read first analog input, divide by 4 to make the range 0-255:
firstSensor = analogRead(3)/4;
// read second analog input, divide by 4 to make the range 0-255:
secondSensor = analogRead(4)/4;
// read third analog input, divide by 4 to make the range 0-255:
thirdSensor = analogRead(5)/4;

// delay 10ms to let the ADC recover:
delay(10);

// send sensor values:
// print each sensor value, then print a comma
Serial.print(firstSensor, DEC);
Serial.print(‘,’);
Serial.print(secondSensor, DEC);
Serial.print(‘,’);
Serial.print(thirdSensor, DEC);

// at the end, send a ‘*’ to end the message:
Serial.print(‘*’);

}
}

Midterm Project: Spiritual Pumpkins

See Spiritual Pumpkins in action.

IMG_20141024_105053

Here is my midterm project. I call them Spiritual Pumpkins. The midterm project was due in October, Halloween time, so I thought it would be fun to do a Halloween-themed project. I love carving pumpkins, and I love the Legend of Zelda.

Zelda_Spiritual_Stones_Pack_by_GGRock70

The idea of Spiritual Pumpkins came from the Spiritual Stones in the Legend of Zelda video game. While working on this project I took the opportunity to share the process with the kids that I teach programming to. They had a blast learning about LED’s.

kids leds

Watch my student’s having fun with LED’s.

Spiritual PumpkinsIMG_20141024_105505  IMG_20141024_105517

Close-ups for details of the carving and light shining from the LED’s.

IMG_20141024_105407 IMG_20141024_105424 IMG_20141024_105432 IMG_20141024_105419 IMG_20141024_105416

SO MUCH SOLDERING.

IMG_20141024_105023 

I don’t even understand how I got burnt there.

//FADE////////////////////////////////////////////////////////////
int led = 9; // the pin that the LED is attached to
int brightness = 0; // how bright the LED is
int fadeAmount = 5; // how many points to fade the LED by

//CHASE////////////////////////////////////////////////////////////
// Simple macros to remember which direction to shift LEDs
#define UP true
#define DOWN false
// Will be used to track how long since last event “fired”
unsigned long previousMillis=0;
// Delay to determine when we see the next LED
unsigned long interval = 250;
// Array with Arduino pins containing LEDs in sequence
byte LEDpins[] = {2,3,4,5,6};
// Variable to track which LED to turn on, start at 000001
int LEDstate=0x01;
// State variable to know which direction to shift
boolean direction=UP;

//FLICKER////////////////////////////////////////////////////////////
int ledPin3 = 11;

//////////////////////////////////////////////////////////////////////
//////////////////////////////VOID_SETUP//////////////////////////////
//////////////////////////////////////////////////////////////////////

void setup() {
//FADE////////////////////////////////////////////////////////////
// declare pin 9 to be an output:
pinMode(led, OUTPUT);

//CHASE////////////////////////////////////////////////////////////
// Set Pins with LEDs to OUTPUT
for (int x=0; x < 5; x++)
pinMode(LEDpins[x], OUTPUT);

//FLICKER////////////////////////////////////////////////////////////
pinMode(ledPin3, OUTPUT);
}

//////////////////////////////////////////////////////////////////////
//////////////////////////////VOID_LOOP///////////////////////////////
//////////////////////////////////////////////////////////////////////

void loop() {
//FADE////////////////////////////////////////////////////////////
// set the brightness of pin 9
analogWrite(led, brightness);
// change the brightness for next time through the loop:
brightness = brightness + fadeAmount;
// reverse the direction of the fading at the ends of the fade:
if (brightness == 0 || brightness == 255) {
fadeAmount = -fadeAmount ;
}
// wait for 30 milliseconds to see the dimming effect
delay(30);

//CHASE////////////////////////////////////////////////////////////
// Set the pins of each LED during each iteration
// You’ll only see something change when “LEDpins” gets updated
for (int x=0; x < 5; x++)
digitalWrite(LEDpins[x], bitRead(LEDstate,x));
// Get current time and determine how long since last check
unsigned long currentMillis = millis();
if ((unsigned long)(currentMillis – previousMillis) >= interval) {
// We’ve waited “interval” amount of time, so let’s do some stuff!
// “Reset” our clock
previousMillis = currentMillis;
if (direction==UP) {
// Use “<<” to “bit-shift” everything to the left once
LEDstate = LEDstate << 1;
// 0x20 is the “last” LED, another shift makes the value 0x40
if (LEDstate == 0x40) {
// turn on the one before “0x20” and reverse direction
LEDstate = 0x10;
direction = DOWN;
}
} else {
// use “>>” to “bit-shift” all bits in LEDstate once to the right
LEDstate = LEDstate >> 1;
// This means we ran out of bits!
if (LEDstate == 0x00) {
// set one ahead so no extra delay
LEDstate = 0x02;
direction = UP;
}
}
}
//FLICKER////////////////////////////////////////////////////////////
analogWrite(ledPin3, random(120)+135);
delay(random(100));
}

Week 7: LOL Shield (Lots of LED’s)

LOL Shield

 See this LOL Shield project in action now.

#include <avr/pgmspace.h> //AVR library for writing to ROM
#include <Charliplexing.h> //Imports the library, which needs to be
//Initialized in setup.

//Sets the time each frame is shown (milliseconds)
const unsigned int blinkdelay = 1000 / 50;

PROGMEM const uint16_t BitMap[][9] = {
//Diaganal swipe across the screen
{1, 0, 0, 0, 0, 0, 0, 0, 0},
{3, 1, 0, 0, 0, 0, 0, 0, 0},
{7, 3, 1, 0, 0, 0, 0, 0, 0},
{15, 7, 3, 1, 0, 0, 0, 0, 0},
{31, 15, 7, 3, 1, 0, 0, 0, 0},
{63, 31, 15, 7, 3, 1, 0, 0, 0},
{127, 63, 31, 15, 7, 3, 1, 0, 0},
{255, 127, 63, 31, 15, 7, 3, 1, 0},
{511, 255, 127, 63, 31, 15, 7, 3, 1},
{1023, 511, 255, 127, 63, 31, 15, 7, 3},
{2047, 1023, 511, 255, 127, 63, 31, 15, 7},
{4095, 2047, 1023, 511, 255, 127, 63, 31, 15},
{8191, 4095, 2047, 1023, 511, 255, 127, 63, 31},
{16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63},
{16383, 16383, 8191, 4095, 2047, 1023, 511, 255, 127},
{16383, 16383, 16383, 8191, 4095, 2047, 1023, 511, 255},
{16383, 16383, 16383, 16383, 8191, 4095, 2047, 1023, 511},
{16383, 16383, 16383, 16383, 16383, 8191, 4095, 2047, 1023},
{16383, 16383, 16383, 16383, 16383, 16383, 8191, 4095, 2047},
{16383, 16383, 16383, 16383, 16383, 16383, 16383, 8191, 4095},
{16383, 16383, 16383, 16383, 16383, 16383, 16383, 16383, 8191},
{16383, 16383, 16383, 16383, 16383, 16383, 16383, 16383, 16383},
{16383, 16383, 16383, 16383, 16383, 16383, 16383, 16383, 16383},
{16382, 16383, 16383, 16383, 16383, 16383, 16383, 16383, 16383},
{16380, 16382, 16383, 16383, 16383, 16383, 16383, 16383, 16383},
{16376, 16380, 16382, 16383, 16383, 16383, 16383, 16383, 16383},
{16368, 16376, 16380, 16382, 16383, 16383, 16383, 16383, 16383},
{16352, 16368, 16376, 16380, 16382, 16383, 16383, 16383, 16383},
{16320, 16352, 16368, 16376, 16380, 16382, 16383, 16383, 16383},
{16256, 16320, 16352, 16368, 16376, 16380, 16382, 16383, 16383},
{16128, 16256, 16320, 16352, 16368, 16376, 16380, 16382, 16383},
{15872, 16128, 16256, 16320, 16352, 16368, 16376, 16380, 16382},
{15360, 15872, 16128, 16256, 16320, 16352, 16368, 16376, 16380},
{14336, 15360, 15872, 16128, 16256, 16320, 16352, 16368, 16376},
{12288, 14336, 15360, 15872, 16128, 16256, 16320, 16352, 16368},
{8192, 12288, 14336, 15360, 15872, 16128, 16256, 16320, 16352},
{0, 8192, 12288, 14336, 15360, 15872, 16128, 16256, 16320},
{0, 0, 8192, 12288, 14336, 15360, 15872, 16128, 16256},
{0, 0, 0, 8192, 12288, 14336, 15360, 15872, 16128},
{0, 0, 0, 0, 8192, 12288, 14336, 15360, 15872},
{0, 0, 0, 0, 0, 8192, 12288, 14336, 15360},
{0, 0, 0, 0, 0, 0, 8192, 12288, 14336},
{0, 0, 0, 0, 0, 0, 0, 8192, 12288},
{0, 0, 0, 0, 0, 0, 0, 0, 8192},
{0, 0, 0, 0, 0, 0, 0, 0, 0},

//Horizontal swipe
{1, 1, 1, 1, 1, 1, 1, 1, 1} ,
{3, 3, 3, 3, 3, 3, 3, 3, 3},
{7, 7, 7, 7, 7, 7, 7, 7, 7},
{15, 15, 15, 15, 15, 15, 15, 15, 15},
{31, 31, 31, 31, 31, 31, 31, 31, 31},
{63, 63, 63, 63, 63, 63, 63, 63, 63},
{127, 127, 127, 127, 127, 127, 127, 127, 127},
{255, 255, 255, 255, 255, 255, 255, 255, 255},
{511, 511, 511, 511, 511, 511, 511, 511, 511},
{1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023},
{2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047},
{4095, 4095, 4095, 4095, 4095, 4095, 4095, 4095, 4095},
{8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191},
{16383, 16383, 16383, 16383, 16383, 16383, 16383, 16383, 16383},
{16382, 16382, 16382, 16382, 16382, 16382, 16382, 16382, 16382},
{16380, 16380, 16380, 16380, 16380, 16380, 16380, 16380, 16380},
{16376, 16376, 16376, 16376, 16376, 16376, 16376, 16376, 16376},
{16368, 16368, 16368, 16368, 16368, 16368, 16368, 16368, 16368},
{16352, 16352, 16352, 16352, 16352, 16352, 16352, 16352, 16352},
{16320, 16320, 16320, 16320, 16320, 16320, 16320, 16320, 16320},
{16256, 16256, 16256, 16256, 16256, 16256, 16256, 16256, 16256},
{16128, 16128, 16128, 16128, 16128, 16128, 16128, 16128, 16128},
{15872, 15872, 15872, 15872, 15872, 15872, 15872, 15872, 15872},
{15360, 15360, 15360, 15360, 15360, 15360, 15360, 15360, 15360},
{14336, 14336, 14336, 14336, 14336, 14336, 14336, 14336, 14336},
{12288, 12288, 12288, 12288, 12288, 12288, 12288, 12288, 12288},
{8192, 8192, 8192, 8192, 8192, 8192, 8192, 8192, 8192},
{0, 0, 0, 0, 0, 0, 0, 0, 0},
{18000}
};

void setup() {
LedSign::Init(DOUBLE_BUFFER | GRAYSCALE); //Initializes the screen
}
void loop() {
for (uint8_t gray = 1; gray < SHADES; gray++)
DisplayBitMap(gray); //Displays the bitmap
}

void DisplayBitMap(uint8_t grayscale)
{
boolean run=true; //While this is true, the screen updates
byte frame = 0; //Frame counter
byte line = 0; //Row counter
unsigned long data; //Temporary storage of the row data
unsigned long start = 0;

while(run == true) {

for(line = 0; line < 9; line++) {

//Here we fetch data from program memory with a pointer.
data = pgm_read_word_near (&BitMap[frame][line]);

//Kills the loop if the kill number is found
if (data==18000){
run=false;
}

//This is where the bit-shifting happens to pull out
//each LED from a row. If the bit is 1, then the LED
//is turned on, otherwise it is turned off.
else for (byte led=0; led<14; ++led) {
if (data & (1<<led)) {
LedSign::Set(led, line, grayscale);
}
else {
LedSign::Set(led, line, 0);
}
}
}

LedSign::Flip(true);

unsigned long end = millis();
unsigned long diff = end – start;
if ( start && (diff < blinkdelay) )
delay( blinkdelay – diff );
start = end;

frame++;
}
}

Weeks 4-6: Piezo Buzzer and Servo Motor w/ Sensors

Octi
Reactive Octi
Based on the pressure or flex applied to the embedded sensors in Octi’s arms, his eyes rotate to make him look either sad or mad.
#include <Servo.h>
Servo myservo;
int servo = 7;
int piezo = 8;
int pressure = A0;
int servo_pos = 0;
int current_pressure = 0;
int current_note = 200;
int current_spin = 1;
void setup() {
  // put your setup code here, to run once:
  pinMode(servo, OUTPUT);
  pinMode(piezo, OUTPUT);
  pinMode(pressure, INPUT);
  myservo.attach(servo);
  Serial.begin(9600);
}
void loop() {
  // put your main code here, to run repeatedly:
  current_pressure = analogRead(pressure);
  Serial.print(current_pressure);
  Serial.print(” “);
  current_note = map(current_pressure, 0, 1024, 200, 2000);
  Serial.print(current_note);
  Serial.print(” “);
  current_spin = map(current_pressure, 0, 1024, 1, 20);
  Serial.println(current_spin);
  tone(piezo, current_note);
  myservo.write(servo_pos);
  servo_pos += 1*current_spin;
}

Week 2: RGB-LED w/ Accelerometer

The LED’s color changes based on orientation of accelerometer.

Watch pretty lights change as I rotate by Arduino.

//reg-led digital pins
int R = 11;
int G = 10;
int B = 9;

//accelerometer analog pins
int Xout = 0; // select the input pin for the sensor
int Yout = 1;
int Zout = 2;

//accelerometer variables
int xVal = 0; // variable to store the value coming from the sensor
int yVal = 0;
int zVal = 0;

//map
int scaledValue;

void setup(){
Serial.begin(9600);
//”AREF” pin – gives specific/precise readings
analogReference(EXTERNAL); // use AREF for reference voltage
}

void loop(){

xVal = analogRead(Xout); // read the value from the sensor
//Serial.println(xVal); //0-1023 Val – find lowest & highest values to map
analogWrite(R,map(xVal, 390,620, 0,255));//0-255 rgb

yVal = analogRead(Yout); // read the value from the sensor
//Serial.println(map(yVal, 390,630, 0,255));
analogWrite(G,map(yVal, 390,630, 0,255));

zVal = analogRead(Zout); // read the value from the sensor
//Serial.println(map(zVal, 390,640, 0,255));
analogWrite(B,map(zVal, 390,640, 0,255));

}

Week 1: My Introduction

Hai gai’s…

My name is Jessy Jo. I ride a scooter because scooters rock. I wear bows in my hair because I like long hair but I hate hair in my face.

Anyway. Here’s a fancy picture of me for reference:

cutie-weirdo
cutie-weirdo

I am a gamer and game designer, an animator, an educator, a social justice junkie, and a “cutie-weirdo“.

I am the co-founder of Win to Learn, Inc., a company that strives to teach kids to code through game design. We use “play” as a way to learn. More recently we have expanded to teach some animation, since I am so versed.

I like the idea of physical computing and want to learn it so that I can teach it to a younger generation. Kids really get me and I really get kids, so it works. Parents go nuts for me.

I’m trying to keep my intro short because I’m sure you’ll learn all about me from my big mouth in class. Nevertheless, here are some links to my work. Enjoy!

| Sweet Teeth | Battle for Boobland | Win to Learn |
| Other Stop-Motion & Motion Graphics |