cimbalo / ltto_library Goto Github PK
View Code? Open in Web Editor NEWThis project forked from rmick/ltto_library
Arduino library for the LTTO/LTX/LTAR Lasertag system (Lazertag)
This project forked from rmick/ltto_library
Arduino library for the LTTO/LTX/LTAR Lasertag system (Lazertag)
/* This is a simple to use LTTO compatible Infra-red communications library, to work with LTTO/LTX/LTAR (Hasbro/Nerf) laser tag systems It works with any Arduino Uno or Mega board. I am a self taught programmer, who has been using Arduino's since early 2015. I am still learning, but my code is now at the point that I am happy to share it. ---------------------------------------------------------------------------------------- CIRCUIT REQUIREMENTS Connect an IR LED between Pin 13 and a 100 ohm resistor to GND. Part # TSAL6200 Connect a 38kHz IR receiver as below Part # TSOP4138 - IR receiver Pin1 (Out) to Arduino Pin 11 - IR receiver Pin2 (Gnd) to Arduino GND - IR receiver Pin3 (Vcc) to Arduino +5v ---------------------------------------------------------------------------------------- GETTING STARTED This library is designed to be very simple for even an Arduino newbie. You must install the LTTO library as well as the EnableInterrupt library (https://github.com/GreyGnome/EnableInterrupt) 1) Make sure that you have a good understanding of these examples. - Basics / Blink - Digital / Button - AnalogReadSerial or DigitalReadSerial - www.arduino.cc/en/Guide/Libraries 2) Start with SendTag or SendLTAG both of which send a tag when the button is pressed. Use the Digital/Button example circuit - just replace the normal LED with an IR LED. - SendTag is for hosted games (be aware that you must have a tagger with same Team # & Player ID in the game for the shot to be received) - SendLTAG is for non hosted games 3) Medic Station is a simple Respawn station that sends a Respawn signal when the button is pressed. Use the Digital/Button example circuit - just replace the normal LED with an IR LED. (This works in hosted games where the MedicMode is enabled) There is an optional delay setting so that the user has to wait XX seconds after pressing the button for the Respawn signal (we use 30 seconds to stop people re-entering the game too quickly) 4) SendTextMessage sends the text 'HELLO' to any gun in range. Use the Digital/Button example circuit - just replace the normal LED with an IR LED. It is a good way to start learning how to send IR messages. Visit wiki.lazerswarm for details on the protocol 5) ReceiveTag sends a message with the details of the tag received to the Arduino Serial Monitor. Connect the IR receiver as per the circuit above, and set the Serial Monitor speed to 115200 baud. 6) ReceiveIR sends a complete decode of all IR messages to the Arduino Serial Monitor. Connect the IR receiver as per the circuit above, and set the Serial Monitor speed to 115200 baud. ---------------------------------------------------------------------------------------- LIST OF METHODS: void sendIR(char type, uint16_t message); bool sendLTAG(byte playerID, byte tagPower); bool sendTag(byte teamID, byte playerID, byte tagPower); bool sendBeacon(bool tagReceived, byte teamID, byte tagPower); bool sendZoneBeacon(byte zoneType, byte teamID); bool sendLTARbeacon(bool tagReceived, bool shieldsActive, byte tagsRemaining, byte unKnown, byte teamID); bool available(); void clearMessageOverwrittenCount(); byte readMessageOverwrittenCount(); char readMessageType(); uint16_t readRawDataPacket(); byte readTeamID(); byte readPlayerID(); byte readShotStrength(); char readBeaconType(); bool readTagReceivedBeacon(); byte readPacketByte(); String readPacketName(); String readDataType(); long int readDataByte(); uint8_t readCheckSumRxByte(); bool readCheckSumOK(); DEBUG METHODS void printBinary(uint16_t number, byte numberOfDigits); void readErrors(); void printIR(char mode); ---------------------------------------------------------------------------------------- CREDITS BaldWisdom.com My first code was copied and pasted from his github https://github.com/osbock/Baldwisdom/blob/master/duino_tag/duino_tag.ino and includes these credits. * Arduino based example of lazertag protocol. * Copyright 2013 Kevin Osborn, Nick Hollander * Free for reuse,just give us a credit (Creative Commons Attribution) * Hook an IR LED up to Digital pin 3 (PWM) for Arduino Uno etc. (look in IRremote library for other platforms. * Uses Ken Shirrif's IRremote library found at: https://github.com/shirriff/Arduino-IRremote ---------------------------------- * lazertag protocol, originally reverse engineered by Aaron Nabil and documented at * http://web.archive.org/web/20090304155723/http://lasertagparts.com/ltto.htm * * 3ms On, 6ms Off, 3ms (preamble) followed by 7 bits spaced apart by 2ms. One is represented by 2ms, zero is 1ms * In regular lazertag mode, the player and team bits are zero, but the last two bits signify how powerful the blast is. * for this example, we show a shot that does one damage and one that does 4 (max) https://www.baldengineer.com/arduino-f-macro.html Another Bald person saved the day when I started to run out SRAM in my Uno and got the usual random lockups. I was just about to upgrade to Mega boards when I found this blog on the F macro, and 10 minutes later had recovered 40% of my SRAM and the project was back on track. Ken Sherriff - for his ubiqitous IR library. Although I no longer use it in the project, it taught me most of what I needed to know to create the current code. I ditched the library for a number of reasons. 1) I needed to use different Pins for the IR_RECEIVE and IR_SEND, as the pins in the library were used for the LCD touch screen. 2) I really wanted duplex send/receive, whereas in Ken's library sending turns off receive. To me this is the MOST important aspect of a LaserTag system, it must be able to be shot whilst it is shooting. Nick Gammon - In the last few months almost everytime I visited the Arduino.cc forum to ask a question, Nick had already posted an answer. After a while I started to read his blogs and other posts, and learn't a massive amount about the low level workings of the Arduino. Tag Ferret - the inventor of the LTTO system, whose various blogs and websites provided much needed background information Lazerswarm - makers of a nice LTTO hosting system, whose WIKI was invaluable for this project. http://wiki.lazerswarm.com Dejan Deletic - a great software engineer who answered numerous questions and always pointed me in the right direction.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.