loading

The next step in usefully using strobing LEDs with the Linkit One board is to get them to respond to a varying condition – for example light levels.

This guide will add components to the previous guide (Linkit One - Part 2 - Strobe lights) I will also modify the code to allow the board to read the value of a potentiometer and apply that to the rate at which the LEDs swap from one to the next, so the speed of the strobe will adjust with changes in light.

Why would you bother – I hear you think.

  • Its an interesting exercise (visual not much use)
  • If you can see the values for the time period change you can plot data for example it would give you a way to track the progress of a solar eclipse
  • You could make a laser tag game.

Theres other uses – but those come in the next guide

I will not be going over setup of the board or wiring other than to include some images from the previous guide – I will include a link to the guide in the last step of this guide.

Step 1: Components

  1. Jumper wires, Bread board 9 x 33 ohm resistors and 9 x low power LED’s (all from the previous guide
  2. Variable resistor (Pot) I’ve used a Lin 220 KOhm unit for this guide
  3. 1 x Light dependent resistor (LDR) there are no markings on mine so I cannot give you a ratting, however as long as it reaches approximately zero resistance when fully covered – then I would say the higher the ratting the better – if you use it for light applications for examples then the use of a low one could result in it topping out before the increasing light levels reach maximum.

Step 2: Wiring Up the Board

The previous wiring should be maintained from the guide (Linkit One - Part 2 - Strobe lights)

The Pins on the board are as follows

  • Middle pin of the Pot to A2 The grey jumper on the next image
  • Right side pin on the Pot to GND white jumper on the next image
  • The left side pin on the Pot to one connection on the Light dependant resistor The brown looking jumper on the next image
  • The remaining LDR connector goes to the 5V pin on the board (sorry ran out of colours this ones also grey but you should be able to pick it out from the other connection.

Step 3: Code

Changes in the code

  • Int has been change to Float for the ledDelay variable
  • A Float variable has been added for the potPin = A2 – (specific care is needed here its not like the Arduino you need the A as part of the A2 or the code will not work correctly)
  • Serial.begin(128000); // opens serial port, sets data rate128000 bps
  • Serial.println("CLEARDATA"); //clears any residual data
  • The value for ledDelay has been set to the value of the potPin – if the Pot was connected by itself then the value would be adjustable by had, however ther is also the LDR this makes the value seen at A2 a variable one dependant upon the available light to which the LDR is exposed to ( simply changing light changing value)
  • A set of Serial.prints have been added to the end to display the potPin values when you open a serial monitor from the tools menu of the Arduino application.

Copy from her into your Arduino Application:

byte ledPin[] = {4,5,6,7,8,9,10,11,12};

float ledDelay(65);

int direction=1;

int currentLED = 0;

unsigned long changeTime;

float potPin = A2;

void setup(){

Serial.begin(128000); // opens serial port, sets data rate128000 bps

Serial.println("CLEARDATA"); //clears any residual data

for (int x=0; x<9; x++){

pinMode(ledPin[x], OUTPUT);}

changeTime = millis();

}

void loop(){

ledDelay = analogRead(potPin);

if ((millis()-changeTime)>ledDelay){

changeLED();

changeTime=millis();

}

}

void changeLED(){

for (int x=0; x<9; x++){

digitalWrite(ledPin[x],LOW);

}

digitalWrite(ledPin[currentLED], HIGH);

currentLED += direction;

if (currentLED ==8){direction = -1;}

if (currentLED ==0){direction = 1;}

Serial.print("DATA,TIME,");

Serial.print(currentLED);

Serial.print(",");

Serial.println(ledDelay);

}

Stop copy here


About This Instructable

253views

5favorites

License:

Bio: Hi I like to have a go at anything that's interesting, from CNC to toy making, recently I have been dismantling an old Cybot ... More »
More by HUKBMBEAR:Easy Planting Pouring Wood Nine Men's Morris 
Add instructable to: