Initial+Testing

=Initial Testing=

To test the Arduino Mega board and power supply the following code was run. The video below demonstrates the summary of results. code format="c" /* * This is a modified version of original program by * Joshua McGinnis, Power LED on Dark. * * This basic example uses simple logic using voltage from * voltage divider circuit of a photoresistor and a resistor * to determine whether light is present or not. * * This program uses simple logic to turn of LED when no light is present. * * This program can eaily modified to turn on LED when light is present * and turn off LED when there is no light present. This can be done by * replacing following code: * * if(val == HIGH) { // if nothing from photo resistor (low light), turn on led * *  digitalWrite(ledPin, LOW); *  delay(500); * * } else { *  digitalWrite(ledPin, HIGH); * * Umair Niaz */

int photoPin = 0; // designate pin 1 as the analog in for the photo resitor int val = 0;

int ledPin = 23; // designate pin 23 as the digital out for the LED

void setup                   // run once, when the sketch starts { Serial.begin(9600); pinMode(ledPin,OUTPUT); // set the pin pinMode(photoPin,OUTPUT); // set the pin }

void loop                    // run over and over again {

val = analogRead(photoPin); // set val equal to the resitor input

if(val == LOW) { // if nothing from photo resistor (low light), turn on led

digitalWrite(ledPin, HIGH); delay(500);

} else { digitalWrite(ledPin, LOW); } Serial.println(val); } code

media type="youtube" key="y8EqelbWwMQ" height="360" width="580" align="center"