# FINAL PROJECT UPDATE

OUR FINAL PROJECT HAS RUN INTO A LOT OF PROBLEMS.  FIRST OFF WE COULD NOT FIGURE OUT HOW TO GET ONE LED TO LIGHT UP AT A TIME. THAT WAS A MAJOR ISSUE, BECAUSE WE WERE USING THE DIMMING IN OUR CODE, WE HAD MORE THEN ONE LED STAY ON AT ONE TIME.

SO WE DECIDED TO TAKE THE DIMMING SECTION OUT OF OUR CODE.

float RGB;
int ldrPin = 0;     // LDR in Analog Input 0 to read the ambient light
int ambientLight;   // variable to store the value of the ambient light
int redLed   = 11;  // red LED in Digital Pin 11 (PWM)
int greenLed = 10;  // green LED in Digital Pin 10 (PWM)
int blueLed  = 9;   // blue LED in Digital Pin 9 (PWM)

void setup(){
pinMode(redLed,OUTPUT);  // tell arduino it’s an output
pinMode(greenLed,OUTPUT);// tell arduino it’s an output
pinMode(blueLed,OUTPUT); // tell arduino it’s an output

// set all the outputs to low
digitalWrite(redLed,LOW);
digitalWrite(greenLed,LOW);
digitalWrite(blueLed,LOW);
}

void loop(){
for (float x=0;x<PI;x=x+0.00001){
RGB=255*abs(sin(x*(180/PI)));           // calculate the brightness for the red led
RGB=255*abs(sin((x+PI/3)*(180/PI)));    // calculate the brightness for the green led
RGB=255*abs(sin((x+(2*PI)/3)*(180/PI)));// calculate the brightness for the blue led
ambientLight=analogRead(ldrPin); // read an store the ambient light
if(ambientLight>600){ // start only if the ambient light is very low
//  write the brightness on the leds
analogWrite(redLed,RGB);
analogWrite(greenLed,RGB);
analogWrite(blueLed,RGB);
}
else{
digitalWrite(redLed,LOW);
digitalWrite(greenLed,LOW);
digitalWrite(blueLed,LOW);
}
for(int i=0;i<3;i++){
if(RGB[i]<1){
delay(100);
}
if(RGB[i]<5){
delay(50);
}
if(RGB[i]<10){
delay(10);
}
if(RGB[i]<100){
delay(5);
}
}
delay(1);
}

}AND WE TOOK OUT THE END PARTS OF THE CODE.

THE LEDS ARE ON PINS 9, 10, 11

The delay we put in was 25,000 milli seconds…which equals 25 seconds.

The void loop is the part of the code we added, and altered…

we changed the analogwrite to digital write….  BILLS OF MATERIALS

3 LEDS GREEN RED AND BLUE

9 VOLT BATTERY

9 VOLT BATTERY HOLDER

ANDUINO MICROCONTROLLER

220 ohm resistor.

ALSO LEARNED THAT THE OHM IS THE SMALLEST,  THEN IT’S KILLO, THEN IT’S MEGA. …… IT’S IMPORTANT TO KNOW THE DIFFERENT RESISTORS.

THE LINK TO CHECK FOR WHAT KIND OF RESISTOR IS

http://www.dannyg.com/examples/res2/resistor.htm

For this project we really had to study forward voltage , anday the current of electricity so that our LED would not burn out.

THE ELECTRICITY GOES THROUGH THE  RESISTOR BEFORE GOING TO THE LEDS……THIS PREVENTS THE LED FROM BURNING OUT. IT CONTROLS THE BRIGHTNESS OF THE LED ALSO.

down below is some videos of me and calye practicing our game