Other Arduino Codes and Videos by Robojax

Using TEMT6000 Phototransistor Ambient Light Sensor for Arduino

دروس آردوینو به فارسی

Using TEMT6000 Phototransistor Ambient Light Sensor for Arduino

his code reads the voltage of common Collector configuration and displays the voltage in Volts.

Schematic diagram for TEMT6000 Module

  

/*
 * This is Arduino Sketch for TEMT6000 Phototransistor Module
 * This code reads the voltage of common Collector configuration
 * and displays the voltage in Volts.
 * V pin is connected to 5V
 * G pin is connected to ground GND
 * S pin is signal connected to A0 of Arduino
 * 
   Written by Ahmad Shamshiri for Robojax.com
 * on May 10, 2018 at 14:14 at Ajax, Ontario, Canada
 * This code is provided at http://robojax.com 
 * Watch Video instruction for this code:https://youtu.be/pxR6e-3XkIk
 */
#define light A0 // define input pin

void setup() {
  // TEMT6000 Roboajx.com code
  Serial.begin(9600);
  
}

void loop() {
   // TEMT6000 Roboajx.com code
  int Lvalue = analogRead(light);// read the light
  int mVolt = map(Lvalue,0, 1023, 0, 5000);// map analogue reading to 5000mV
  float volt =(double)mVolt/1000;// convert millivolt to volt

  Serial.print(mVolt);// print millivolt
  Serial.print( "mV ");
  Serial.print(volt,3);// print volts with 3 decimal places
  Serial.println( "V ");
  delay(1000);// wait for 1000 milliseconds
   // TEMT6000 Roboajx.com code

}   

If you found this tutorial helpful, please support me so I can continue creating content like this. support me via PayPal