Using the TSL230- Measuring Light Intensity and Activating Motors

Colleen Carrier, Sara Range

Program Description:

Through the use of the TSL230 Light Intensity to Light Frequency chip, one can sense different intensities within the room. By hooking up a DC motor to the bread board, we programmed the motor to turn on when the chip detects different intensities. Soon we'll have a car that drives or stops based on the intensity of light. Project Problems:1.) When we first bought this chip that nobody knew how to work it, we were under the impression that it detects frequency. However, it does not. It detects intensity and is supposed to convert intensity to frequency. Once we found this out, we were able write the coding properly and be able to read the numbers that the chip was giving us. Also because it detects different intensities instead of frequencies and we did not find this out till last minute, we had to change our project completely to fit the idea of intensity instead of frequency. Originally, we were supposed to develop a car that stops when it sees a red light, and goes when it sees green-- like a stop light.

2.) The lessons that we looked at online were not much help to us, so we had to basically develop our own code and figure out the exact circuitry ourselves. we researched a lot of new coding to make this project work for us.

void loop() { // this is just for debugging // it shows that you can sample freq whenever you need it // even though it is calculated once a second // I am dislplaying it every 2 seconds // note that the first time that freq is calculated, it is bogus count++; Serial.print(count); Serial.print("\tuW/cm: "); Serial.print(getUwattCm2(), DEC); Serial.print("\tfrequency: "); Serial.println(frequency, DEC);

delay(10); if (frequency > 5000) { Serial.println("cmon work!"); // this is just to tell us that the chip is in fact detecting something digitalWrite(mo, LOW); // the motor is off when light intensity is more than 5000 delay(100);

} else { digitalWrite(mo, HIGH); // when the chip is detecting light intensity less than 5000, the motor turns on delay(100); }}

long getUwattCm2() { // copy pulse counter and multiply. // the multiplication is necessary for the current // frequency scaling level.

frequency = curPulseCount * scale;

// get uW observed - assume 640nm wavelength // calc_sensitivity is our divide-by to map to a given signal strength // for a given sensitivity (each level of greater sensitivity reduces the signal // (uW) by a factor of 10)