GithubHelp home page GithubHelp logo

trfevzi / ledmap Goto Github PK

View Code? Open in Web Editor NEW

This project forked from devicercode/ledmap

0.0 1.0 0.0 78 KB

Processing and Arduino code for automatic addressable LED mapping

License: MIT License

C++ 33.56% Processing 66.44%

ledmap's Introduction

LEDmap

Processing and Arduino code for automatic addressable LED mapping

Ever have trouble showing fancy patterns on LEDs because your layout is chaotic or a zigzag and you can't address the lights easily in order? This code is designed to give you a mapping output that contains the coordinates of each light ready to paste into your arduino pattern code and it does so semi-automatically by using a webcam to detect the position of each light.

The code here is in two parts - the arduino part and the processing part. You need to flash your arduino compatible microcontroller of choice with the arduino part, then connect to it using the (hopefully) platform independent processing sketch.

Dependencies

Arduino part
Processing part

You quite possibly have all but the blobDetection library already. There are lots of tutorials available elsewhere if you need assistance with installing libraries but it should be very simple with the new library managers.

How to use

You will need the above libraries installed and you need to have a webcam for the processing side (at the moment, there will be other options in the future) then you are ready to start.

  1. Edit the arduino code LEDmap.ino to suit your LED type, number and pins, refer to fastLED docs if you have trouble with this part
  2. The LEDs should start flashing orange to indicate controller is ready and waiting
  3. Connect PC/laptop with serial cable
  4. Run the processing code LEDmap.pde
  5. Select your webcam and the controllers serial port from the drop-downs
  6. Use the 'showall leds' button and the threshold and brightness sliders to make sure it's detecting blobs around all lights
  7. Press automap and it will start to generate a mapping, it will stop automatically when finished
  8. Select an output and save as a text file
  9. The text file now contains code to paste into your own code that has the LED mappings in a style as mentioned in more detail below.

Ouput style

Currently there's one useable output style when you save the mapping - outputting byte values (0-255) for each coordinate in the format:

For convenience saving the output creates a line for copy and pasting with the NUM_LEDS so an example output is:

#define NUM_LEDS 20
struct map2d mapping ={
{248,249,249,248,252,237,233,234,233,233,211,212,212,212,215,187,185,184,184,184},
{73,100,127,157,182,183,155,128,101,73,72,100,127,154,182,179,151,123,96,68}
};

You will need the following defined to make use of the pasted mapping:

struct map2d {
  byte x[NUM_LEDS];
  byte y[NUM_LEDS];
};

It's small, it's simple and it's easy to address the coords of an LED by using for example

int xcoord = mapping.x[position];
int ycoord = mapping.y[position];

See the included "Examples" folder for examples of useage using fastLED, as you can see it takes very little code to make complex patterns that work on any layout of pixels spread over an area.

The map coordinates are 0,0 in the top left, 255,255 in the bottom right.

If you are reading this just now stay tuned for more documentation and proper 1.0 release when I'm a bit happier with how useful it is but it should be useable right now. This is a completely rewritten from scratch version of my old unwieldy hacky code, it lacks a huge number of features which I will hopefully be adding in soon, see 'issues' for some of them.

ledmap's People

Contributors

devicercode avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.