Skip to content

Infineon/sensor-light

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Light Sensor

Overview

This library provides functions to support use of a phototransistor ambient light sensor such as the TEMT6000 as used on the CY8CKIT-028-TFT shield. It uses an ADC to read the relative light level which is returned a a percentage of maximum brightness (0-100).

This library is generic and can be used with any ADC based light sensor.

Quick Start

  1. Create an empty application
  2. Add this library to the application
  3. Add the following code to your application. This example initializes the Light Sensor and reads the relative brightness.

\note This example is targeted for Arduino-based boards. Define LIGHT_SENSOR_PIN as appropriate for your hardware.

#include "cyhal.h"
#include "cybsp.h"
#include "mtb_light_sensor.h"

#define LIGHT_SENSOR_PIN (CYBSP_A0)

cyhal_adc_t adc;
mtb_light_sensor_t light_sensor;

int main(void)
{
    cy_rslt_t rslt;

    rslt = cybsp_init();
    CY_ASSERT(rslt == CY_RSLT_SUCCESS);

    rslt = cyhal_adc_init(&adc, LIGHT_SENSOR_PIN, NULL);
    CY_ASSERT(rslt == CY_RSLT_SUCCESS);

    rslt = mtb_light_sensor_init(&light_sensor, &adc, LIGHT_SENSOR_PIN);
    CY_ASSERT(rslt == CY_RSLT_SUCCESS);

    uint8_t light = mtb_light_sensor_light_level(&light_sensor);

    for(;;) { }
}

More information


© Cypress Semiconductor Corporation (an Infineon company) or an affiliate of Cypress Semiconductor Corporation, 2019-2021.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages