INFOSTATION CORP
  • Home
  • Gallery
  • Contact
  • About
  • Digital Goods
  • Home
  • Gallery
  • Contact
  • About
  • Digital Goods
Search

Sensor - Photoresistor Module

28/5/2019

Comments

 
I will discuss the photoresistor module today. Photoresistor is a sensor that can sense the amount of light intensity in your environment. This is typically used if you want to control any devices when the environment is dark or when it is light. Our photoresistor module has 3 pins. The left pin is the signal pin, where you connect it to the analog pin in Arduino for as input.  The middle pin is the VCC pin (+5V) and the right pin is GND pin, where it should connect to the ground pin of arduino.
Picture
The input value coming from the photoresistor produces voltage value, a maximum of +5V and a minimum of 0V. Once the arduino receives this voltage value, this will be converted into a number value, from 0 to 1023 value. if the input value is 1023, it means the voltage value produced by photoresistor is +5V. This will only happens when the photoresistor detects a very bright light in the environment, in which it causes the photoresistor reduces its resistance value. ​
Let's try the photoresistor module functionality by uploading our code below.
int sensorPin = A1;    // set the input pin for the photoresistor
int led = 13;      // set the pin for the LED
int sensorValue = 0;  // set the variable to store the value coming from the photoresistor sensor

void setup() {
  pinMode(ledPin, OUTPUT);
}

void loop() {
  // read the value from the photoresistor sensor:
  sensorValue = analogRead(sensorPin);
  // turn on the LED
  digitalWrite(led, HIGH);
  // pause for milliseconds based on value from photoresistor:
  delay(sensorValue);
  // turn off the LED
  digitalWrite(led, LOW);
  // pause for milliseconds based on value from photoresistor
  delay(sensorValue);
}


    
Let's discuss the code inside the loop() function. The analogRead() returns a number between 0 and 1023 based on the voltage produced on Analog pin 1 of Arduino. The value returns will be used as the parameter value for the delay() function. The higher the number, the longer the pause of the system.
Comments

    Noel Anonas

    Author, coder, Innovator
    email:
    ​noelqanonas@gmail.com
    My Resume
    ​Couse Outline for Java

    Picture

    Archives

    July 2019
    June 2019
    May 2019
    June 2017

    Categories

    All

    RSS Feed

    View my profile on LinkedIn
  • Home
  • Gallery
  • Contact
  • About
  • Digital Goods