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(‘*’);

}
}

Leave a Reply

Your email address will not be published. Required fields are marked *