Quantcast
Channel: Tigar » Sensors
Viewing all articles
Browse latest Browse all 8

LDR and the JeeNode

$
0
0

In a previous post I gave an example of an LDR with the Arduino. In case you want to use it with a JeeNode you can connect the LDR between the AIO and GND. JeeLabs has a great page about LDR in combination with the on-board RF12 chipset to transmit the data between two nodes. A first step to your own Wireless Sensor Network (WSN).

I’ll give a small code sample just to read the measure light values when the LDR is connect between AIO (A) and GND (G) of port 3 of your JeeNode. For the extended code version please visit the original page at JeeLabs.

#include <Ports.h>
#include <RF12.h>

Port ldr (3);

void setup () {
    Serial.begin(57600);
    ldr.mode2(INPUT);
    ldr.digiWrite2(1);
}

void loop()
{
    // Measure value; convert the 0..1023 value to a 0.255 value
     byte value = 255 - ldr.anaRead() / 4;

    // Print the 'light  value'
    Serial.println((int) value);

   // wait for a second
    delay(1000);
}

 

 

 

 


Viewing all articles
Browse latest Browse all 8

Trending Articles