Examples - Electronic Bricks - Electronic Analog Light

Get access to the Analog Light Brick.

This program gives you a basic understanding of how to use the analog Light Brick. Just connect it to analog input port (1) on your micro-controller and print the analog readings to the serial monitor.

/*
Example: How to use the 'Analog Light Sensor Electronic Brick'
Usage: Connect Brick to analog pin 1 on the Seeduino Shield
*/
// Define the analog input pin for the light sensor
int sensorInputPin = 1;
// Declare variable "light"
int light;

void setup()
{
        // Invoke Serial Interface for debugging purposes
        Serial.begin(9600);
}

void loop()
{
        // Read the sensor
        light = analogRead(sensorInputPin);
        // Output to console or computer
        Serial.println(light);
        // Delay the printline function for 0.5 seconds
        delay(500);
}



This website has been archived and is no longer maintained.