Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save futureshocked/1fe6c8a7005ea80dbdeb9612b3d06ae0 to your computer and use it in GitHub Desktop.
Save futureshocked/1fe6c8a7005ea80dbdeb9612b3d06ae0 to your computer and use it in GitHub Desktop.
This sketch demonstrates how to use the Grove analog light sensor.
/* 04.020 - Grove analog light sensor
This sketch demonstrates how to use the Grove analog light sensor.
The analog light sensor is an analog device. It outputs a voltage
level that depends on the intensity of ambient light.
Upload this sketch and start the Serial monitor (you can also use
the serial plotter). Wave your hand over the sensor and notice the
change in the output displayed in the monitor.
Components
----------
- Grove Base Shield
- An Arduino Uno compatible board (such as Arduino/Genuino Uno or Seeeduino)
- Grove analog light sensor
- One Grove cable
IDE
---
Arduino IDE
Libraries
---------
-
Connections
-----------
Use a Grove cable to connect the light sensor module to Base Shield connector A0.
Other information
-----------------
- Use this sketch along side the video lecture 02.020 of Grove For Busy People
- Grove documentation: http://wiki.seeedstudio.com/Grove-Light_Sensor/
- Grove component: https://txplo.re/35e13
Github Gist
-----------
<script src="https://gist.github.com/futureshocked/1fe6c8a7005ea80dbdeb9612b3d06ae0.js"></script>
https://gist.github.com/futureshocked/1fe6c8a7005ea80dbdeb9612b3d06ae0
For course information, please go to https://techexplorations.com/product/grove-for-busy-people/
Created on July 5 2019 by Peter Dalmaris
*/
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}
// the loop routine runs over and over again forever:
void loop() {
// read the input on analog pin 0 (available through Grove connector A0):
int sensorValue = analogRead(A0);
// print out the value you read:
Serial.println(sensorValue);
delay(1); // delay in between reads for stability
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment