Final Project- Motion Sensor Tie


ALS_Blog_LogoMotion Sensor Tie

what is this project? This is a project that involve 2 bracelet and 2 persons team project. One part of the project is design as the input and the other part of the bracelet is output.My original design of the project is one person wearing bracelet on their arm, has an Adafruit flora, a motion sensor (flora accelerometer) and jumper wire and the other person arm would have led light, however we change it led light will be put inside of a tie and glove will have inside the accelerometer and the flora mainboard. When one teammate with the motion sensor tilt his/her arm(glove), the other teammate would wear a tie that would be output for led light display.

This project is a different for various reason first the name is different, second the older project was bracelets and they use processor. We use a glove and inserted the accelerometer and flora atmega and put RGB led light inside of a tie. The original project the designer use processor and code to make the led light go around in a circle however in my project the led light is program to random and we are only using arduino software.

Material needed

jumper wire red,yellow and black, wire stripper, wire cutterusb cable, a tie and glove (any of your choice), a hot gun, tape, a knife (look at collage below for more details and visual image)

  • Microcontroller/main device

Adafruit flora v1.0a with Atmega32u4 chip (micro processor)  

  • Input devices                                                                  

Adaruit Flora accelerometer/compass sensor   version lsm 303 DLHC

  • Output device

Adafruit Flora RGB NeoPixel v2 in this project use only 6

project name is formally known as motion light sensor change to Motion Sensor Tie

unnamed (1)

3D paper image of the project                         Project  develop that we was going to use:

  unnamed                     download bracelet

we change our project to a tie and glove presentation because we ran out of time to purchase two bracelets.

Testing the adafruit flora mainboard and adafruit flora RGB Neo Pixel v2  and Adaruit Flora accelerometer/compass sensor using alligator cables. The adafruit floara neo pixel is very bright

Step 1: Research details on materials to develop this project

Adafruit flora1.0a Atmega32u4 chip is similar to arduino uno but it is designed as wearable electronics platform and small enough to put anywhere for creative interactions. The device use microprocessor called Atmega32u4. Flora is 1.75 diameter.Flora mainboard is the main piece of the puzzle to make this project come to life. It has large pads to connect premium stainless steel thread. The pad are layout to make it easy to connect flora various components like sensors, ultimate gps, motion sensor (accelerometer/compass), flora light sensor ir+visible lux sensor or flora led neopixel. Flora has built in usb HID support and can act act like a keyboard or mouse. Flora is perfect for designing your own expressive and functional electronic fashion Arduino software v1.0.5 has included flora driver, libraries and examples. This version of flora use mini b connector.


   Quick Breakdown

small reset button to reset the system

one side of the board is used for input like for example the accelerometer (type of sensor) will go onto the side label scl/sda/gnd/3.3v/

the other label 3.3v/d10/d6/d9 use for output like the flora RGB neopixel (type of actuator)

Ground (no power). there is 2 GNDs for a reason

Simple connector last PWM  SCI (clockline) is the i2c clock pin – its required to talk to the acelerometer
Pulse Width Modulation (PWM) rapidly change the output pin high to low over fixed period of time depending on how the code is design.On flora main board D9, D10, D6 are pwn pins

Digital pins is use for connection of the flora RGB neopixel

Serial data analyzer SDA (data line) is the i2c data pin – its required to talk to the accelerometer

Scl and sda are like brother and sister. It is used to communicate with 12c/ two wire interface (twi) device like for example lcd screens

Rx and Tx- Recieve data and Transfer data to serial monitor using code

void setup()                    // run once, when the sketch starts
  Serial.begin(9600);           // set up Serial library at 9600 bps
  Serial.println("Hello world!");  // prints hello with ending line break 

3.3 volt: pulls current of 100mA max to the board

Vbatt: is used when you want to power something like Neopixels or a servo, a device that require more than the 150mA available from the on board regular.

flora is mainly powered through jst connector (usb connection). JST input (button) (on&off switch) is polarity protected. Vbatt control by using data Rx and Tx for motion sensors different type of control of power. Do not use vbatt as an input because it might damage your battery if you also plug in the usb connector to a computer.

Important note for beginner

It is difficult to destroy the Adafruit flora v1.0a (Atmega32u4) by connecting a battery backward polarized connectors and protection diodes. The power supply designed to be flexible. flora is fabric friendly. There is 2 on board japan solder less terminal connectors with protection diodes for the external battery packs from 3.5v to 9v DC. It can run on 3v but 3.5v-5v or higher if you trying to add something more powerful. In addition, can use Lilon/LiPoly, LiFe, Alkaline or rechargeable NiMh/NiCad batteries of any size. for more information visit

Definitions: Japan solder less terminal (jst) battery connector is white electrical connectors mounted onto the printed circuit board (pcb) (flora).

polarized:restrict the vibration of transverse wave or partially to one direction

The accelerometer and flora mainboard has a 12C (sda/scl) interface it is also known as 12c bus used to interact with real-time clocks, digital potentiometers, temperature sensors, digital compasses, memory chips, FM radio circuits, I/O expanders, LCD controllers, amplifiers

on arduino uno the 12C Bus is analogs A4(SDA) and A5(SCL)

Please note: must download the drivers and specific libraries. when first plug in the flora mainboard make sure serial port and board is adafruit flora is correct. 

download the arduino ide v1.05 software with flora installed not the new verizon v1.06 why? Because it does not have flora board installed.

analysis this pdf for steps to install driver because for windows the serial port would not work properly unless the driver was installed correctly

steps to install a library on windows, mac, linux

websites to download the libraries
adafruit accelerometer
adafruit neopixel

In addition when plug in mini usb the circuit will light up green. Before uploading any code whether it manually structured or an example from arduino built in verify for any error in the code then upload to the code to the board. When the code upload the board when light up red and will see Transfer data (Tx) and recieve (Rx) data light flicker on.

For insurance that the adafruit flora mainboard working properly input the code into arduino software and plug in the flora check the serial port and board is correct then upload the program to flora. you should see on board blinking led.

  1. // Pin D7 has an LED connected on FLORA .
  2. // give it a name:
  3. int led = 7;
  5. // the setup routine runs once when you press reset:
  6. void setup() {
  7. // initialize the digital pin as an output.
  8. pinMode(led, OUTPUT);
  9. }
  11. // the loop routine runs over and over again forever:
  12. void loop() {
  13. digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
  14. delay(1000); // wait for a second
  15. digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
  16. delay(1000); // wait for a second
  17. }


6 standtest to test flora neopixel

Step 2: connection and layout


Adafruit flora mainboard connect to adaruit flora accelerometer/compass sensor 4 connections

mainboard (GND) jumper wire connect to accelerometer (GND)

mainboard (scl) jumper wire connect to accelerometer (scl)

mainboard (sda) jumper wire connect to accelerometer (sda)

mainboard (3.3v) jumper wire connect to accelerometer (3.3v)

Adafruit flora mainboard connect to adaruit flora RGB Neo Pixel v2 3 connections

Adafruit flora mainboard (Vbatt) jumper wire connect to flora RGB Neo (+)

Adafruit flora mainboard (D6) jumper wire connect to flora RGB Neo (arrow pointing toward led light)

Adafruit flora mainboard (GND) jumper wire connect to flora RGB Neo(bottom of led light)

wire connection

Red wire for power (+)

Black wire for Ground (gnd)( – )

Yellow wire for signal (–>)

Adaruit flora RGB Neo Pixel v2 3 connections

PLEASE NOTE: connection the RGB Neo led lights depend on how many led you will be using for your project. For more infomation visit diagram below good exampleflora_PB282306

 Step 3: The code, toubleshooting & debug=successful project

key note the code has to match with the circuit. for example: on the flora you connect the flora RGB led lights to D6 then in the code it has to be D6. move_thershold number was change because the higher the higher the number the lower the sensitivity in the accelerometer.

  • Motion Sensor Tie code

#include <Wire.h>                              //library to connect TWI/12c like sda/scl on the board
#include <Adafruit_LSM303.h>      //library for accelerometer/motion sensor
#include <Adafruit_NeoPixel.h>     //library for flora neopixel

// Parameter 1 = number of pixels in strip
// Parameter 2 = pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
// NEO_RGB Pixels are wired for RGB bitstream
// NEO_GRB Pixels are wired for GRB bitstream
// NEO_KHZ400 400 KHz bitstream (e.g. FLORA pixels)
// NEO_KHZ800 800 KHz bitstream (e.g. High Density LED strip)
Adafruit_NeoPixel strip = Adafruit_NeoPixel(6, 12, NEO_GRB + NEO_KHZ800);

//set neopixel to D12 on the flora mainboard
Adafruit_LSM303 lsm;

// Here is where you can put in your favorite colors that will appear!
// just add new {nnn, nnn, nnn}, lines. They will be picked out randomly
//R    G    B
unit8_t myFavoriteColors[][3] = {{200, 0, 200}, // purple
{200, 0, 0}, // red
{200, 200, 200}, // white
{ 0, 200, 0}, // green
{ 0, 0, 200}, // blue
// don’t edit the line below
#define FAVCOLORS sizeof(myFavoriteColors) / 3

// mess with this number to adjust TWINklitude 🙂
// lower number = more sensitive

void setup()                          //set up the program to do specific action
Serial.begin(9600);           //command serial monitor to activate

// Try to initialize and warn if we couldn’t detect the chip
if (!lsm.begin())                    //if library is detect start serial monitor
Serial.println(“Oops … unable to initialize the LSM303. Check your wiring!”);
while (1);                //if library not detected go to turn off strips
strip.begin();         //; // Initialize all pixels to ‘off’

void loop()                    //if the accelerometer library is detected continue on to void loop
// Take a reading of accellerometer data;
Serial.print(“Accel X: “); Serial.print(lsm.accelData.x); Serial.print(” “);
Serial.print(“Y: “); Serial.print(lsm.accelData.y); Serial.print(” “);
Serial.print(“Z: “); Serial.print(lsm.accelData.z); Serial.print(” “);

// Get the magnitude (length) of the 3 axis vector
double storedVector = lsm.accelData.x*lsm.accelData.x;
storedVector += lsm.accelData.y*lsm.accelData.y;
storedVector += lsm.accelData.z*lsm.accelData.z;
storedVector = sqrt(storedVector);
Serial.print(“Len: “); Serial.println(storedVector);

// wait a bit

// get new data!;                  //Retrieve Rx and Transfer new data
double newVector = lsm.accelData.x*lsm.accelData.x;
newVector += lsm.accelData.y*lsm.accelData.y;
newVector += lsm.accelData.z*lsm.accelData.z;
newVector = sqrt(newVector);
Serial.print(“New Len: “); Serial.println(newVector);

// are we moving
if (abs(newVector – storedVector) > MOVE_THRESHOLD) {
flashRandom(5, 1); // first number is ‘wait’ delay, shorter num == shorter twinkle
flashRandom(5, 3); // second number is how many neopixels to simultaneously light up
flashRandom(5, 2);

void flashRandom(int wait, uint8_t howmany) {

for(uint16_t i=0; i<howmany; i++) {
// pick a random favorite color!
int c = random(FAVCOLORS);              //different variable for different colors
int red = myFavoriteColors[c][0];
int green = myFavoriteColors[c][1];
int blue = myFavoriteColors[c][2];

// get a random pixel from the list
int j = random(strip.numPixels());
//Serial.print(“Lighting up “); Serial.println(j);

// now we will ‘fade’ it in 5 steps
for (int x=0; x < 5; x++) {
int r = red * (x+1); r /= 5;
int g = green * (x+1); g /= 5;
int b = blue * (x+1); b /= 5;

strip.setPixelColor(j, strip.Color(r, g, b));;
// & fade out in 5 steps
for (int x=5; x >= 0; x–) {            //set the direction of digital pins
int r = red * x; r /= 5;
int g = green * x; g /= 5;
int b = blue * x; b /= 5;

strip.setPixelColor(j, strip.Color(r, g, b));;
// LEDs will be off when done (they are faded to 0)

Once code is upload to flora and the device is properly connected. Open the serial monitor to see accelerometer working with movement. Also in the code it is program to send signal to serial monitor.


Issue and troubleshooting why?

I wanted to connected six RGB LED light and the code wasn’t working. me and my team partner decide to take apart the project and start over just to make sure the connection is secure first and then work on the code.

When I connected all six neopixels together and tested on a strand test they all worked fine. When switched to the code that uses the accelorometer only two pixels light up. When I checked the volts they were all working fine. They worked according to the strandtest. So I took off two NeoPixels making it down to four and the strand test worked.

I wanted to connected six RGB LED light and the code wasn’t working. me and my team partner decide to take apart the project and start over just to make sure the connection is secure first and then work on the code.

me and my team partner had  a weak connection when we decide to strip the jumper wire and tie them to the components. it show that it was a shortage in the pixels communication.

Multimeter Testing:


all issue was resolve when we soldered all components. It is a very secure connection. Further analysis the code to make sure it match the connection and as a result it was a successful project.

New project have red glove with flora mainboard and accelerometer hot gun with tape

The tie has 6 flora neopixel hot gun in with tape and red,yellow and black jumper wire soldered on to maintain great connection no shortage.

unnamed (1)

fun fact section

The software and devices is compatible with Mac, Linux and windows

For different connections can also use conductive fabric, conductive paint, alligator clips

For different type of micro controller boards similar to Arduino and Flora there is mainboard called lilypad, gemma and trinket


Part 3: Arduino Projects

In the arduino project book I will be doing project number 4 and 5. The 1st  project is called color mixing lamp. In the book it says this project take approximately 45 minutes to complete. For me it may have taken me about an hour because I would add another 15 minutes to set up and how i would like to wire the circuit. A new idea that I have tried when dealing with arduino is get piece of paper and pen and write out detail for detail how the curcuit board and arduino uno going to be wired. I have done this because with previous project I have encounter issues and i thought it was good idea for troubleshooting. Make sure on the arduino software in the tools tab the serial port is correct and board is correct.

The materials needs for this project would include:

220 OHM Resistors (3)                                        10 KILOHMS Resistors (3)

RGB LED has 4 legs                                            13 jumper wire

Photoresistors (3)                                                   Breadboard

Arduino Uno                                                             red green blue gels

rbg led  Photoresistorresistor

The purpose of this project is to use red green blue tri color led, photoresisor and red green or blue gels to fade the leds to the specific colors (color mixing lamp). For example, using an green gel on photoresistor the RGB led should display color green.

I will explain the role of each component on the circuit board to make this happen.On the arduino uno you can see next to pin number digital (PWM~).Pulse Width Modulation (PMW) can be used to fade leds. PMW turn the output pins high or low like change lights on and off. The percentage of time a pin is high in a period it called duty cycle. A lower duty cycle will give dimmer LED than higher duty cycle. The arduino uno has 6 pins set aside for PMW (digital pins 3,5,6,10,11). Notice the ~ symbol next to each pin. Photoresistors are sensors (input) they change resistance depending on the amount of light that hit the sensor. On the board 3 photoresistor connect one side  to power and another side to 10 kilohms resistor that would go to ground.

The resistor along with photoresistor form a voltage provider; the voltage at the point where they meet is proportional to the ratio of their resistance. when resistance change of the photoresistor changes when light it so would voltage, it is rule of ohm’s laws. In addition along side resistor are 3 jumper wire connected to analog in pins 0-2. Each analog is coded for a specific color like green over photoresistor connected to analog 1 or A1.

The most interesting component on the circuit board is 4 leg RGB LED. First I would like you to note that 3 220 ohms resistor are connected to 3 pwm pins 9-11 because they determine how much voltage the RGB led should receive out of 5 voltage. It has a red green and blue element inside plus a leg for ground (the cathode).

Color Mixing Lamp Code

//declare the RGB led, the value never change
const int greenLEDPin = 9;
const int redLEDPin = 11;
const int blueLEDPin = 10;

//link input and output
const int redSensorPin = A0;
const int greenSensorPin = A1;
const int blueSensorPin = A2;

//add variable for incoming sensor value and for the output of value when using fade
//declare variables
int redValue = 0;
int greenValue = 0;
int blueValue = 0;

int redSensorValue = 0;
int greenSensorValue = 0;
int blueSensorValue = 0;

//begins communication between board and pc
void setup (){
pinMode(greenLEDPin, OUTPUT); //define led pins as output
pinMode(redLEDPin, OUTPUT);
pinMode(blueLEDPin, OUTPUT);
void loop(){
//read the value of each light sensor
//analogRead store the value in appropriate variable with ADC
redSensorValue = analogRead(redSensorPin);
delay(5); //take analog digital converter a millisecond to read each sensor
greenSensorValue = analogRead(greenSensorPin);
blueSensorValue = analogRead(blueSensorPin);

//print values onto serial monitor on pc
Serial.print(“Raw Sensor Value \t Red: “); //\t is like tab key on keyboard
Serial.print(“\t Green: “);
Serial.print(“\t Blue; “);
redValue = redSensorValue/4;
greenValue = greenSensorValue/4;
blueValue = blueSensorValue/4;
Serial.print(“mapped Sensor Value \t Red: “);
Serial.print(“\t Green: “);
Serial.print(“\t blue: “);
//the function to change 4 leg led brightness (pwm) is analogwrite
analogWrite (redLEDPin, redValue);
analogWrite (greenLEDPin, greenValue);
analogWrite (blueLEDPin, blueValue);


Part 2 Project 5 Mood Cue

This project uses a new component called servo motor. The objective is to design servo motor to rotate motor arm by turn the potentiometer. It is suppose to determine what would you are in today.I think it detect I was in bad mood because mines did not work completely.According to the book this project take a hour to complete. There are a lot of few new materials I will be using this project. The materials include:

Potentiometer                    100UF Capacitor (2)

Servo Motor                        Male header Pins (3)

Motor Arm                          Jumper wire (8)

all materialsP5

mini details of servo motor

Servo motors are special motors that only spin around 180 degree not a full circle. Servo motor has a certain number of pulses that tell them what angle to move to. The pulses always come at the same time intervals, but the width varies between 1000 to 2000 microseconds. Arduino software come with library that allow you easily control the motor.Servo only rotate 180 degrees and your analog input goes 0-1023. Use the function map() to change scale values coming from the potentiometer.

The set up process

The circuit board is first connected to jumper cables of 5 voltage and ground.  There is a 100uf capacitor in front of the potentiometer. Capacitor role is to store and release electrical energy in circuit. The potentiometer is a voltage divider. It has 3 pins, 1 pin connect to ground, middle pin connect to analog in and last pin connect to power. When turn the knob it will change the voltage between analog pin and power. NOTE: potentiometer is two piece component that has to be put together, the knob and 3 pin piece is separate.

The servo motor has 3 wires. red wire for power,black wire for ground and white wire for control or pin ~9. Note: the servo motor has female connectors and you would need to use 3 male connectors for this circuit. In addition the motor arm would have to be placed on the servo motor. When servo motor start to move it will draw more current than if it was in motion. Placing 100uf capacitor across power and ground next to male connectors it will balance out voltage on the circuit. The servo motor is using pwm pin and it is converted using analog digital converter A0.

The Mood cue code

#include <Servo.h>                      //new library because new feature and has to be declared

Servo myServo;                         //declare the object servo 

//declare variable

//set up named constant for the pin the potentiometer attached to and variable to hold the analog input value

int const potPin = A0;

int potVal;

int angle;
void setup(){                                      //servo is attach to pin 9
Serial.begin(9600);                    //serial connection the value can be checked on pc everytime turn potentimeter
void loop(){                                 //read analog input and print out the value to the serial monitor
potVal = analogRead(potPin);
Serial.print(“potVal: “);
angle = map(potVal, 0, 1023, 0, 179);
Serial.print(“, angle: “);

Arduino Uno Spaceship interface project

SAMSUNGToday I am starting a new project called Arduino Project. The actual project is called “spaceship interface” and in this project I will be using arduino board(look like more board from pc) and bread board(white). in addition component are 1 green and 2 red led’s, 4 resistors, switch (button) and jumper wires. I will be building a circuit and there will be video to show the arduino code interacting with the arduino board.


The first in the arduino book

The one red LED suppose light up on breadboard automatically but I had to unplug usb and troubleshoot. The middle picture has three leds 2 red and 1 green. I put the resistors in the wrong way on breadboard.the last picture show the right way when the code is upload to the board the red led is automatically turn on then when button is press the signal go to green then back to red and it going until release the button.


int switchState=0;

void setup(){

void loop(){
switchState = digitalRead(2);
//if switchState is LOW. turn the green LED on and turn red LED off.
if (switchState == LOW) { //the button is not pressed
digitalWrite(3, HIGH); //green LED
digitalWrite(4, LOW); //red LED
digitalWrite(5, LOW); //red LED
else { //the button proceed
digitalWrite(3, LOW);
digitalWrite(4, LOW);
digitalWrite(5, HIGH);

delay(250); //wait for quarter second
// toogle the LEDs
digitalWrite(4, HIGH);
digitalWrite(5, LOW);
delay(250); //wait for quarter second

} // go back to the beginning of the loop

revise code

this program keep the middle red Led light on and only light up red and green on turn on when button is press.


int switchState=0;

void setup(){


void loop(){
switchState = digitalRead(2);
//if switchState is LOW. turn the green LED on and turn red LED off.
if (switchState == LOW) { //the button is not pressed
digitalWrite(3, LOW); //green LED
digitalWrite(4, HIGH); //red LED
digitalWrite(5, LOW); //red LED
else { //the button proceed
digitalWrite(3, LOW);
digitalWrite(4, LOW);
digitalWrite(5, HIGH);

delay(255); //wait for quarter second
// toogle the LEDs
digitalWrite(4, HIGH);
digitalWrite(5, LOW);
delay(300); //wait for quarter second

} // go back to the beginning of the loop

another revise code

When button is press the midddle red light led goes off for a second


int switchState=0;

void setup(){

void loop(){
switchState = digitalRead(2);
//if switchState is LOW. turn the green LED on and turn red LED off.
if (switchState == LOW) { //the button is not pressed
digitalWrite(3, HIGH); //green LED
digitalWrite(4, HIGH); //red LED
digitalWrite(5, LOW); //red LED
else { //the button proceed
digitalWrite(3, HIGH);
digitalWrite(4, HIGH);
digitalWrite(5, LOW);

delay(1255); //wait for quarter second
// toogle the LEDs
digitalWrite(4, LOW);
digitalWrite(5, LOW);
delay(2000); //wait for quarter second

} // go back to the beginning of the loop


ProtoSnap Pro Mini on Sparkfun

CAM00221 A new project I am working on is from called Protosnap pro mini.First, I would like to say I do not like program but I am doing this project with open mind and love to adventure new ideas. I will be programming Protosnap pro mini to light in different color,make noise or break components apart to use for something else.  As of today I am entering into open source software of arduino programing. What is arduino? It’s an open-source physical computing platform based on a simple microcontroller board, and a development environment for writing software for the board. In other word, arduino is programming language that is written in java and similar to c++, however this program was created for certain type of hardware like Protosnap pro mini. Arduino was design to teach basic programming. Programmer experiment with arduino to do various commands to control switches, sensors and various other lights or motors.

The image below show Protosnap pro mini.

CAM00226 CAM00224

Breakdown of what in shown in the 2 images

the FTDI board is the section where you plug into computer it has standard mini B to usb cable

button that is connected to pin 7 as well as UCC(power source) and GND(ground)

Light sensors that connected to GND(ground), A0 (analog pins), and UCC(power)

RGB LED connected various pins, pin 5= G(green),pin 6=B(blue), pin 3=R(red) lately UCC

they call this pin the pin to annoy your roommate the buzzer =pin 2 and GND

Last but not least the proto boardsection the circles next to buzzor, allow you to solder additional sensors or anything else onto the protosnap pro mini

If you turn over the device you can trace where everything connected and see how communication works between various senors and outputs to the mircrocontroller. The program is delivered pre programmed if you press a button it will make noise or if you cover your finger over light sensor, the RED LED display various colors.

Here the start of program process in arduino. I use sample from the website to guide me through the progress of program the Protosnap pro mini. The following was coded to activate button when it is press. int buttonPin = 7 which mean button is connected to pin 7. The program input and output is through electronically, if it reads high (5V), then that means the button is not being pressed. While a low (0V) indicates that the button is being pressed. The program is coded in conditions of if or else statement to activate the Protosnap pro mini to make sound on low voltage which mean button is being press and when no button being press it is high voltage and LED is off.

int buttonPin = 7; // button is connected to pin 7
int ledPin = 13; // LED’s connected to pin 13
int buttonStatus; // variable we’ll use to store the button’s status

void setup() {
pinMode(buttonPin, INPUT); // Initialize the buttonPin as input
pinMode(ledPin, OUTPUT); // The LED is an output

void loop() {
/* First read the status of the button
HIGH = button is NOT pressed
LOW = button IS pressed */
buttonStatus = digitalRead(buttonPin);

if (buttonStatus == LOW) {
digitalWrite(ledPin, HIGH); // If the button’s pressed turn the LED on
else {
digitalWrite(ledPin, LOW); // Otherwise, turn the LED off

int button = 7;
int buzzer = 2;
int light = A0;
int red = 3;
int blue = 6;
int green = 5;

void setup() 
pinMode(buzzer, OUTPUT);  
pinMode(red, OUTPUT);  
pinMode(green, OUTPUT);  
pinMode(blue, OUTPUT);

pinMode(button, INPUT);
 Serial.println("I am a protosnap, waiting to hear space bar:");

void loop() 
  if(Serial.available() > 0)
    if( == 32)
    Serial.println("I HEARD THAT, OH SNAP!");
while(digitalRead(button) == LOW)
digitalWrite(buzzer, HIGH);
digitalWrite(buzzer, LOW);

int temp = analogRead(light);
if(temp > 100)
  digitalWrite(red, HIGH);
  digitalWrite(green, HIGH);
  digitalWrite(blue, HIGH);
  digitalWrite(red, LOW);
  digitalWrite(green, HIGH);
  digitalWrite(blue, HIGH);
    digitalWrite(red, HIGH);
  digitalWrite(green, LOW);
  digitalWrite(blue, HIGH);
    digitalWrite(red, HIGH);
  digitalWrite(green, HIGH);
  digitalWrite(blue, LOW);

My program that I have put together

int variableColor;                                         // declare the light pins
void setup(){
pinMode(7,INPUT);                                      //declare button connected to pin 7
digitalWrite(7,HIGH);                                    //setting internal pull up resistor to off when set to HIGH 0 voltage
pinMode(3,OUTPUT);                                   //declare the RGB LED pins
void loop() {
variableColor= analogRead (A0);                     //read light sensor

//when button is press provided a path to GND(ground) setting voltage to low to display color of choice declared

digitalWrite(6,LOW);                              //signal the buzzer to display color blue when turn on
digitalWrite(3,HIGH);                             //signal the controller to turn off red when buzzer press
digitalWrite(5,HIGH);                             //signal the controller to turn off green when buzzer press
tone (2,1100,1000);        //control sound of buzzer, allow the buzzor to be active when press for 1 second (duration)
delay (1000);                                        //after 1 second sound from buzzer stops