Final Project

TA Gauntlet

Materials

  • Legos
  • arduino
  • usb battery pack
  • small bread board
  • neopixel strip (4 pixels)
  • 5 touch sensors
  • 5 buzzers
  • male to female wires
  • male to male wires

Code
/*
 * Author:George Cepeda
 * Date:4/10/17
 * ToDo:
 * -Code in pins to use
 * -create function that will play a tone out of buzzer
 * -add led to light up when buzzer it played
 * -Create functions to light up neopixel strip and ring
 * -create an array to store frequencies
 * -make more coffee
 */
//——————————————————————————————–
#include<Adafruit_NeoPixel.h>

#define PINS 9
#define PINR 8

Adafruit_NeoPixel strip=Adafruit_NeoPixel(4,PINS,NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel ring=Adafruit_NeoPixel(12,PINR,NEO_GRB + NEO_KHZ800);

int button=A0;
int button1=A1;
int button2=A2;
int button3=A3;
int button4=A4;

int buzzer0 = 13;
int buzzer1=12;
int buzzer2=11;
int buzzer3=10;

int count=0;
int count2=0;
int x=0;
int y=0;
int z=0;
//——————————————————————————————–
void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  pinMode(buzzer0,OUTPUT);
  pinMode(buzzer1,OUTPUT);
  pinMode(buzzer2,OUTPUT);
  pinMode(buzzer3,OUTPUT);

  pinMode(button,INPUT);
  pinMode(button1,INPUT);
  pinMode(button2,INPUT);
  pinMode(button3,INPUT);
  pinMode(button4,INPUT);

  strip.begin();
  strip.show();

  ring.begin();
  ring.show();
}//end of setup
//——————————————————————————————–
void loop() {
  // put your main code here, to run repeatedly:
  ringAround(count2);
  if(digitalRead(button)==HIGH){
    colorChange(count);
    count++;
  }
  if(count == 6){
    count = 0;
  }

  if(count ==0){
    x=255;
    y=0;
    z=0;
  }
  else if(count==1){
    x=0;
    y=0;
    z=255;
  }
  else if(count==2){
    x=180;
    y=180;
    z=180;
  }
   else if(count==3){
    x=0;
    y=255;
    z=0;
  }
  else if(count==4){
    x=255;
    y=255;
    z=0;
  }
  else if(count==5){
    x=255;
    y=0;
    z=255;
  }

  if(digitalRead(button1)==HIGH){
   playNote(count,buzzer0);
   singlePixel(0,x,y,z);
  }
  if(digitalRead(button2)==HIGH){
    playNote(count,buzzer1);
    singlePixel(1,x,y,z);
  }
  if(digitalRead(button3)==HIGH){
    playNote(count,buzzer2);
    singlePixel(2,x,y,z);
  }
  if(digitalRead(button4)==HIGH){
    playNote(count,buzzer3);
    singlePixel(3,x,y,z);
  }

  count2++;

  if(count2 == 2){
    count2 = 0;
  }
}//end of loop
//——————————————————————————————–
void playNote(int counter, int buzzer){
  int notePlay[6][4]={{200,250,300,350},{400,450,500,550},{600,650,700,750},{800,850,900,950},{1000,1050,1100,1150},{1200,1250,1300,1350}};
  if(buzzer==13){
    tone(buzzer0,notePlay[counter][0],50);
  }
  if(buzzer ==12){
    tone(buzzer1,notePlay[counter][1],50);
  }
  if(buzzer==11){
    tone(buzzer2,notePlay[counter][2],50);
  }
  if(buzzer ==10){
    tone(buzzer3,notePlay[counter][3],50);
  }
}//end of playNote
//——————————————————————————————–
void singlePixel(int pixelNo,int red, int gre, int blu){
  int i;
  for(i=0;i<4;i++){
    strip.setPixelColor(i,0,0,0);
  }
  strip.setPixelColor(pixelNo,red,gre,blu);
  strip.show();
}//end of singlePixel
//——————————————————————————————–
void colorChange(int count){
  int x=0;
  int y=0;
  int z=0;
    if(count ==0){
    x=255;
    y=0;
    z=0;
  }
  else if(count==1){
    x=0;
    y=0;
    z=255;
  }
  else if(count==2){
    x=180;
    y=180;
    z=180;
  }
   else if(count==3){
    x=0;
    y=255;
    z=0;
  }
  else if(count==4){
    x=255;
    y=255;
    z=0;
  }
  else if(count==5){
    x=255;
    y=0;
    z=255;
  }
  int i;
  for(i=0;i<4;i++){
    strip.setPixelColor(i,x,y,z);
  }
  strip.show();
}//end of colorChange
//——————————————————————————————–
void ringAround(int count){
  int red=0;
  int gre=0;
  int blu=0;
  int red2=0;
  int gre2=0;
  int blu2=0;
  if(count ==0){
    red=255;
    gre=0;
    blu=0;
    red2=0;
    gre2=0;
    blu2=255;
  }
  else if(count==1){
    red=0;
    gre=0;
    blu=255;
    red2=255;
    gre2=0;
    blu2=0;
  }

  int i;
  for(i=0;i<6;i++){
    ring.setPixelColor(i,red,gre,blu);
    //ring.setPixelColor(i+1,red,gre,blu);
    ring.setPixelColor(i+6,red2,gre2,blu2);
    //ring.setPixelColor(i+7,red2,gre,blu2);
    ring.show();
    delay(25);
  }
  for(i=0;i<6;i++){
    //ring.setPixelColor(i,blu,gre,red);
    ring.setPixelColor(i,red2,gre2,blu2);
    //ring.setPixelColor(i+6,red,gre,blu);
    ring.setPixelColor(i+6,red,gre,blu);
    ring.show();
    delay(25);
  }

}

//——————————————————————————————–

Video

Methods

While designing this I decided I would focus on the wiring. I had begun simply by getting two touch sensors to work with two neopixels and buzzers. The image below shows this beginning phase.

After this I had decided to follow up by completely wiring all the components and getting the resulting image.

The next part of this project was trying to come up with a method of containing this mess. I decided to use legos because they are easy to acquire and allow for flexiblity. I had begun by building around the arduino board.

Then once the outside had begun to take shape I began to lay down the ground work for the different components. In the image following there is a raised platform that is meant to hold up the neopixel strip to allow for easy visiblity and a gap in the side for the touch sensors to peek out of.