Final Project Individual Meetings

Each of the groups had to meet with the professor to discuss their progress towards the final. For our group one of the challenges was to write a code that would get our project to behave the way we wanted it to. So our professor was instrumental in giving us guidance to piece the code together. We troubled him with a lot of questions and he stayed with our group extremely late one night going through all the code, line by line, correcting errors and cleaning up the phrasing.

The way we wanted our code to behave is the following: we wanted to have one master light on while the program was at rest, illuminating the entire piece to display it all. Then, once the wheel is spun, one LED illuminates one row for twelve rotations (this is equal to the number of animations we had in each row) and then passes on to the next row and the next row and just continues to cycle trhough while the wheel is in motion. However, should the wheel stop, it needs to start up again on the first and bottom row and not the random place it stopped. So, there were a lot of variables we had to be careful of and the code had to be clean in order for all these things to work.

We also at one point had a code for MIDI – because we were thinking that we will have music playing while the wheel is in motion, but we never managed to arrange that in the end.

Here is an example of the code we used:

// dekay microceconds or millys
int hallSensor = 2; //hall sensor pin

int hallValue = 0; //hall isensor value

boolean switchAlreadyPressed = false;

int LED1 = 8; //standard LED pin

int LED2 = 9;

int LED3 = 10;

int LED4 = 11;

int prevLED = 0;

int frame = 1; // count frames

int currentLoop = 0;

long lastPressTime=0; // mileys what if stuck on a censer

int stopCounter = 0; //checks for non-rotation


char note = 30; // The MIDI note value to be played

int lastNotePlayed = 0; // note turned on when you press the switch

int notechange = 1;

void setup()


Serial.begin (31250); // for MIDI

//Serial.begin(9600);// start serial port at 9600 bps:

pinMode(hallSensor, INPUT);

pinMode(LED1, OUTPUT);

pinMode(LED2, OUTPUT);

pinMode(LED3, OUTPUT);

pinMode(LED4, OUTPUT);


void loop()


//read digital value from the Hall

hallValue = digitalRead(hallSensor);

//Serial.println(irValue, DEC); // Print the DEC of sensor


//analogWrite(LED, irValue);

if (frame >= 1 && frame < 13) {

currentLoop = LED1;

else if (frame >= 13 && frame < 25) {

currentLoop = LED2;

else if (frame >= 25 && frame < 37) {

currentLoop = LED3;

else if (frame >= 37 && frame < 49) {

currentLoop = LED4;


if (hallValue == 1 && switchAlreadyPressed == false) {

switchAlreadyPressed = true;

digitalWrite(currentLoop, HIGH);
prevLED = currentLoop;

frame = frame + 1;

if (frame > 48) {
frame = 1;
stopCounter = 0;

noteOn(0x90, note, 0x40);

noteOn(0x90, lastNotePlayed, 0x00);

lastNotePlayed = note;

note = note + notechange;

if (note>=90) {

notechange = -notechange;


if (note<=30) {

notechange = -notechange;



if (hallValue == 0 && switchAlreadyPressed == true) {

digitalWrite(prevLED, LOW);

switchAlreadyPressed = false;

if (stopCounter > 1000) {

// Lights on! it’s stopped!


// delay(10);


void noteOn(char cmd, char data1, char data2) {

Serial.print(cmd, BYTE);

Serial.print(data1, BYTE);

Serial.print(data2, BYTE);



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s