Skip to content

Commit

Permalink
Arduino IDE 1.5 library compliance, add .zip package
Browse files Browse the repository at this point in the history
  • Loading branch information
alextaujenis committed Oct 10, 2015
1 parent 9fe1be2 commit a18ebb5
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 20 deletions.
78 changes: 64 additions & 14 deletions README.md
@@ -1,21 +1,20 @@
#Arduino Light Sensor Library
A simple library for reading photoresistors.
Read and calibrate photoresistors.

##Example Setup
0. Wire up a photoresistor to Arduino **pin A0**
0. Wire up a photoresistor to Arduino pin A0
0. Install this library and load the example sketch on to an Arduino
0. Open a serial connection at 115200 BAUD
0. Watch a stream of the current light percentage

##[example.ino](https://github.com/alextaujenis/RBD_LightSensor/blob/master/example/example.ino)
**Example Sketch**

#include <RBD_LightSensor.h>

#define BAUD 115200
RBD::LightSensor light_sensor(A0);

void setup() {
Serial.begin(BAUD);
Serial.begin(115200);
}

void loop() {
Expand All @@ -27,37 +26,88 @@ A simple library for reading photoresistors.
##Public Methods

* [constructor(pin)](#constructorpin)
<hr />
* [setFloor()](#setfloorvalue)
* [setCeiling()](#setceilingvalue)
* [resetFloor()](#resetfloor)
* [resetCeiling()](#resetceiling)
<hr />
* [getValue()](#getvalue)
* [getInverseValue()](#getinversevalue)
* [getPercentValue()](#getpercentvalue)
* [getInversePercentValue()](#getinversepercentvalue)
* [setFloor()](#setfloor)
* [setCeiling()](#setceiling)

##constructor(pin)
Create a new sensor and pass in the Arduino pin number.

RBD::LightSensor light_sensor(A0);

void setup() {
...
}

##setFloor(value)
Provide an integer from 0 - 1023 to calibrate the sensor with a lower bounds of light detection. This will adjust the scale for all methods that return a value in this library, but will not adjust their documented output range. Calibrate the floor with help from [getRawValue()](#getrawvalue).

void setup() {
light_sensor.setFloor(10);
}

##setCeiling(value)
Provide an integer from 0 - 1023 to calibrate the sensor with an upper bounds of light detection. This will adjust the scale for all methods that return a value in this library, but will not adjust their documented output range. Calibrate the ceiling with help from [getRawValue()](#getrawvalue).

void setup() {
light_sensor.setCeiling(999);
}

##resetFloor()
Change the [setFloor()](#setfloorvalue) value back to 0, which also resets the lower bounds of the scale for all methods that return a value in this library.

void setup() {
light_sensor.resetFloor();
}

##resetCeiling()
Change the [setCeiling()](#setceilingvalue) value back to 1023, which also resets the upper bounds of the scale for all methods that return a value in this library.

void setup() {
light_sensor.resetCeiling();
}

##getValue()
Returns an integer from 0 - 1023 for the current light level.
Returns an integer from 0 - 1023 for the current light level adjusted for the [setFloor()](#setfloorvalue) and [setCeiling()](#setceilingvalue) values. If the floor or ceiling are not set, this method will return [getRawValue()](#getrawvalue).

void loop() {
light_sensor.getValue();
}

light_sensor.getValue();
##getRawValue()
Returns an integer from 0 - 1023 for the current light level reading from the sensor. Use this method to calibrate [setFloor()](#setfloorvalue) and [setCeiling()](#setceilingvalue).

void loop() {
light_sensor.getRawValue();
}

##getInverseValue()
Returns an integer from 1023 - 0 for the opposite of the current light level.

light_sensor.getInverseValue();
void loop() {
light_sensor.getInverseValue();
}

##getPercentValue()
Returns an integer from 0 - 100 for the current light level percentage.
Returns an integer from 0 - 100 for the current light percentage.

light_sensor.getPercentValue();
void loop() {
light_sensor.getPercentValue();
}

##getInversePercentValue()
Returns an integer from 100 - 0 for the opposite of the current light level percentage.
Returns an integer from 100 - 0 for the opposite of the current light percentage.

light_sensor.getInversePercentValue();
void loop() {
light_sensor.getInversePercentValue();
}

#License
This code is available under the [MIT License](http://opensource.org/licenses/mit-license.php).
@@ -1,14 +1,14 @@
// Arduino Light Sensor Example - Continuously print a light sensor reading
// Arduino RBD Light Sensor Library v1.0.0 Example - Continuously print a light sensor reading percentage.
// https://github.com/alextaujenis/RBD_LightSensor
// Copyright 2015 Alex Taujenis
// MIT License

#include <RBD_LightSensor.h>

#define BAUD 115200
RBD::LightSensor light_sensor(A0);

void setup() {
Serial.begin(BAUD);
Serial.begin(115200);
}

void loop() {
Expand Down
Binary file added extras/RBD_LightSensor.zip
Binary file not shown.
10 changes: 10 additions & 0 deletions keywords.txt
@@ -0,0 +1,10 @@
LightSensor KEYWORD1
getValue KEYWORD2
getRawValue KEYWORD2
getInverseValue KEYWORD2
getPercentValue KEYWORD2
getInversePercentValue KEYWORD2
setFloor KEYWORD2
setCeiling KEYWORD2
resetFloor KEYWORD2
resetCeiling KEYWORD2
9 changes: 9 additions & 0 deletions library.properties
@@ -0,0 +1,9 @@
name=RBD_LightSensor
version=1.0.0
author=Alex Taujenis <alex.taujenis@gmail.com>
maintainer=Alex Taujenis <alex.taujenis@gmail.com>
sentence=Read and calibrate photoresistors.
paragraph=Read and calibrate photoresistors.
category=Sensors
url=https://github.com/alextaujenis/RBD_LightSensor
architectures=avr
3 changes: 2 additions & 1 deletion RBD_LightSensor.cpp → src/RBD_LightSensor.cpp
@@ -1,4 +1,5 @@
// Arduino RBD Light Sensor Library - A simple library for reading photoresistors
// Arduino RBD Light Sensor Library v1.0.0 - Read and calibrate photoresistors.
// https://github.com/alextaujenis/RBD_LightSensor
// Copyright 2015 Alex Taujenis
// MIT License

Expand Down
5 changes: 3 additions & 2 deletions RBD_LightSensor.h → src/RBD_LightSensor.h
@@ -1,4 +1,5 @@
// Arduino RBD Light Sensor Library - A simple library for reading photoresistors
// Arduino RBD Light Sensor Library v1.0.0 - Read and calibrate photoresistors.
// https://github.com/alextaujenis/RBD_LightSensor
// Copyright 2015 Alex Taujenis
// MIT License

Expand All @@ -10,7 +11,7 @@
namespace RBD {
class LightSensor {
public:
LightSensor(int pint);
LightSensor(int pin);
int getValue();
int getRawValue();
int getInverseValue();
Expand Down

0 comments on commit a18ebb5

Please sign in to comment.