May 04

Laser Tag Update 5/3/15

My deliverables from last month were to:
1. Build a receiver unit. (IR receivers with indicator LED)
2. Adjust code for first game played

1. I arranged IR receivers in a circle,and they all read. I soldered them onto a spare piece of board and built two. After the fact, I decided to add an additional LED onto the receivers so that you would have LED indication on the lens tube when you are tagged or when you send a tag.
2. I changed how my LED's (for indication, not for tagging) turn on and off. I wrote a function that handles all of the indication LED's. With some modification, I could have it run RGB LED's and change their colors without using the built in PWM. The color may change a little bit when you send or receive a tag, but other than that, it should be able to control them pretty easily (during the time that you send or receive a tag, you would not be turning the LED on or off, so the color may be a little different.)

Note: I could change my code that sends and receives tags to send/receive a pulse and then go back into the main loop until I need to send/receive a pulse again. I'm not sure that I'll need to do this, but it is a possibility if I want to run through my main loop faster (and not have to wait for a tag send/receive to complete before going through the main loop).

At this point, I have two tag units, they both are running the current code, and I am ready to actually test playing laser tag. During that test, I should figure out what I should add to make the game play better. I have some other items that I would like to add, and in no particular order, here are some of them:

To add Later:
1. Telegraphing
2. Health bars
3. Shields
4. Bases

Based on trying to make a game type similar to Star Wars Battlefront, I should make spawn bases next. I can work on telegraphing and shields after I have places to respawn from. I can add allowing players to capture spawn points later. (I could add a certain number of respawns for a game type). So, here are my next steps:

Do Next:
1. Test the game with the current tag units: get feedback on what I should add to the devices
2. Begin work on spawn bases (unless telegraphing, health, shields, etc. comes back as something people want more)

Apr 05

Laser Tag Update 4/5/15

My deliverables from two weeks ago were:
1. Rewrite the bill of materials for the tag unit
2. Purchase three additional units
3. (Optional): test tag distances with different protocol timing.

I sorta updated my bill of materials. I have purchased most things from mouser.com, so I have a record of everything that I've purchased and will be able to purchase more if I need to.
I have now purchased materials to build four additional units. Why four? That will give me enough materials to have 5 units. So I could have some asymmetric game play (4v1, 3v2, etc.) or just have up to five people test the things. Or one will break. Who knows.

Do Next:
It will take a week or so for the parts to ship to me, and in the meantime I should prepare for the first game. The only next step I can think of is:
1. Build a receiver unit. It should be able to receive tags from a wide angle (360 degrees is nice, but not necessary). It should have an indicator LED on it.
2. Adjust the code for the first game played.
I am trying to build the minimum viable product. That means the minimum that I can do to make this work is what I should do.

For the first part, I basically need an array of IR receivers that are looking in different directions for a tag. I'm planning on using around 8 right now, because each of the ones that I'm using has a 45 degree field of vision. With 8, I get 360 degrees. I will have to mount that on the tag unit so that you can be tagged from any direction.
I should put an indicator LED on this part. This should go on top of the lens tube. In fact, I could build this in two parts so that you could still see down the center of the tube in order to aim.

For the second part, I need to make the code react to getting tagged in some way so that I can play a game with it. What is the most basic game that I want to play? Standard death match. Each player can get hit a certain number of times. They are out after hit a certain number of times. I need to add some code to keep track of the number of times someone has been hit, and if that counter reaches 0, they are out (I could have the indicator LED stay on or something.
If I want to make the game last for a certain amount of time, I could use a timer on my phone.

For future work, I can get stuff laser cut here:
http://www.cherrylaser.com/
http://www.lasersoverlosangeles.com/

Mar 09

Laser tag update 3/8/15

I missed last week's update, but I still worked on the laser tag project. I just didn't post. Well, here's to make up for lost time:

My deliverables from last week were:

1. Change IR LED current to 1 Ampere. Done.
2. Get distance tests for 1 A with 4.5" lens and a 1" lens. Not done.

So, I did upgrade the board a bit. I was using a solderless breadboard for my prototyping, but it was difficult to hold the darn thing together while aiming at my receiver board. Since I need to make a prototype anyway, I built a version on perfboard that had a breadboard layout on it. That way, my prototype would be sturdy enough that I could walk around with it and test it. I changed the current draw up to about 1 Amp as well. I am not using the 4.5" lens, and instead am using a 3.49" lens that is a standalone lens (the 4.5" lens is encased).

Specifications:

Voltage for LED: 5 V
Resistance for LED: Seven (x7) 33 Ohm resistors in parallel, resulting in 4.7 Ohm total resistance.
Current for LED: 1.06 (max is 1A)
Lens Diameter: 3.49"
Lens Focal Length: 9.5" +/- 0.125"
Max Transmission distance: ?? (not tested)

The purpose of this prototype was to build a unit that could be carried around. I used cardboard as my building material, as it is easy to cut, I have a bunch of it after purchasing stuff, and I can build things with it really quickly. I don't care about making it look pretty at the moment. I just need to see if it will work.

This is the first laser tag prototype

This is the first laser tag prototype

I will do distance tests eventually. However, currently, I have my receiver (which is basically another tag unit) turn on an LED when it is tagged. However, I can't see the little LED very well when I am standing 90 feet away, so I'll need to hook up my laptop and walk away, tag the receiver, then walk back. I'll do it eventually. Not enough time these past two weeks.

Another fun fact about using a larger lens. I empirically found the focal length by focusing the light of the sun (which is as close to a collimated source as I can get. If you have a better solution than focusing your light on something 92 million miles away, please let me know). When I did that, I noticed that the spot is larger than the spot of light I got when using a smaller lens. This is beneficial because the LED is not a point source, but is 5 mm in diameter. Using a larger lens will allow the focal point to have a larger diameter, so I will be able to collimate more light.

I will also mention to check for floating inputs. I didn't solder on the receiver initially, as I was pressed for time. That meant that the input was left floating (I didn't turn on internal pull-up resistors, since originally, there was a receiver there). My tag unit would stop tagging for some reason. I thought it was a power supply issue, code issue, and eventually tracked down that I had a floating input. Oops. I soldered the receiver in, and everything worked fine. If I'd taken the time to solder that last bit on, I wouldn't have been frustrated with the unit upon building it. Let that be a lesson.

Eventually, this needs to be turned into a tag unit that I can run around with and send/receive tags. Here's a short list of work that I will need to do eventually:

1. Build an enclosure - should be done after prototype done
2. Look at multiple IR receivers - (simplest way may be to add multiple receivers to the unit. Current ones don't have 360 degree field of view)
3. Test using 1 resistor instead of 7.
4. Determine what connection you want between your LED and tag unit. (maybe for the final unit, you have a red LED next to the IR)
5. Build multiple devices and test them in the field!

Future work (after first game):

1. Add LCD
2. Add RGB LED?
3. Add 58 kHz receiver for other types of tags
4. Make different lens combinations with different resistors on them with different tag rates

So, based on those things, I should probably test adding multiple IR receivers to my project and make it work with multiple receivers as my next step.

Next Steps:

1. Test multiple receivers. I have a few extra, so I shouldn't have to buy any more to do these tests.

Feb 16

Geocache Puzzle Box Code

https://github.com/gukropina/GeoCachePuzzleBox/

For those of you who want to view it here, here it is:

/*This is my geocache box code. I used ladyada's tutorial on how to wire it, along
with the lcd display, and am using her library. This code is based on her example sketches for
the gps unit, lcd, along with other people's code and forum conversations on the topic

WHERE I AM SO FAR:
I have the distance calculator, destination calculator, attempts working, and check date function working.

I need to start adding the hardware modules (locking mechanism) and building the box.
*/

#include <Adafruit_GPS.h>
#include <SoftwareSerial.h>
#include <math.h> //I need the cosine function, so I need to include math
#include <EEPROM.h>

SoftwareSerial mySerial(3, 2);
Adafruit_GPS GPS(&mySerial); // If using hardware serial (e.g. Arduino Mega), enable this line instead:
//Adafruit_GPS GPS(&Serial1);

/**********************
DEBUGGING
**********************/
const int serialDebug = 0; //serial debugging. 1 for active, 0 for off
const int lcdDebug = 0; //lcd debugging. 1 for active, 0 for off
#define GPSECHO false //echo GPS data to serial consol
int resetCounter = false; //this resets the number of tries you have until the box opens itself. true resets the counter to 1 (for first attempt)

//variable
int firstOn = 0; //first time I turned this thing on, I want this to be true

//GPS stuff
boolean usingInterrupt = false; //we're not using the interrupt
void useInterrupt(boolean); // Func prototype keeps Arduino 0023 happy

//lcd library too
#include LiquidCrystal lcd(7, 8, 6, 10, 11, 12); // initialize the library with the numbers of the interface pins

//EEPROM
int address = 0; //the number of attempts is stored in address 0 in EEPROM

/**********
//Constants
***********/

//Destination
//I'm doing all of my calculations with the latitude and longitude in degrees, since that's what the haversine formula needs,
//therefore, I need to convert my coordinates into degrees in order to determine where I am using this formula.
//You have to put these two numbers into the function directly
//these have 6-7 decimal points of accuracy. Therefore, my code should account for that

//Santa Monica Pier, 25 miles from house
const float destinationLat = 34.007426; //latitude of destination (Santa Monica Pier) in DEGREES
const float destinationLong = 118.499823; //positive longitude of Santa Monica Pier in DEGREES
const float NemaDestinationLat = 3400.4456; //NEMA sentance latitude for Santa Monica Pier
const float NemaDestinationLong = 11829.9894; //NEMA sentance longitude for Santa Monica Pier
//NEMA sentence is degrees (2 decimals Lat, 3 decimals Long), minutes (two decimals.four decimals)

/*
//Luxor, Las Vegas, 36.095511,-115.176033, 212.5 miles from house
const float destinationLat = 36.095511; //latitude of destination in DEGREES
const float destinationLong = 115.176033; //positive longitude in DEGREES
const float NemaDestinationLat = 3605.73066; //NEMA sentance latitude
const float NemaDestinationLong = 11510.56198; //NEMA sentance longitude
*/
/*
After comparing the distance between my NEMA converted distance and a location, I was .6912 miles off. I'm going to give myself a mile
just to be safe. I can also check the location directly, which was accurate, but did not give me good distance measurements
*/
const float maxMilesAway = 1; // Max miles away for box to open (1760 yards). This is for calculating distance away.
//This is less accurate than comparing raw NEMA sentance output because of float limitations
const float maxGPSAway = .1; //this is .1 minutes away (from NEMA sentence). 1 minutes is 1 nautical mile, so this is .115 miles, or 200 yards
const int dlay = 2000; //longest delay during lcd debug

const long waitTime = 300000; //longest I'll wait for a fix before timeing out and turing off (ms)

const int maxAttempts = 50; //maximum number of attempts to open the box
const int offPin = 4; //digital pin to turn off the device
//note: digital pin 13 fluctuates during power on. I can't really use this pin.

//Servo pins
const int servoPin = 9; //servo on pin 9

//Other destinations:
/* latitude, longitude
42.999155,-71.47135 //island in the middle of a river in Manchester, NH. Approximately 3,000 miles away from house
34.160331, -118.131934 //Roscoe's House of Chicken and Waffles, 1.76 miles away from house
34.007426, -118.499823 //Stanta Monica Pier, in degrees 25 miles away
36.095511,-115.176033 //The Luxor, Las Vegas

const float destinationLat = 34.007426; //latitude of destination (Santa Monica Pier) in DEGREES
const float destinationLong = 118.499823; //positive longitude of Santa Monica Pier in DEGREES
const float NemaDestinationLat = 3400.45138 //NEMA sentance latitude for Santa Monica Pier
const float NemaDestinationLong = 11829.99178 //NEMA sentance longitude for Santa Monica Pier
*/

void setup()
{
if (serialDebug == 1){
Serial.begin(115200); // connect at 115200 so we can read the GPS fast enough and echo without dropping chars
Serial.println("Grant's GPS Present Test");
}
lcd.begin(16, 2); //begin lcd

GPS.begin(9600); //GPS uses 9600 baud
GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCGGA); //RMC (recommended minimum) and GGA (fix data) including altitude
GPS.sendCommand(PMTK_SET_NMEA_UPDATE_1HZ); // 1 Hz update rate
useInterrupt(true); //see if using interrups

//set pins to output/input
pinMode(offPin, OUTPUT);
pinMode(servoPin, OUTPUT);
digitalWrite(servoPin, LOW);

//servo stuff
//myservo.attach(servoPin);

}

SIGNAL(TIMER0_COMPA_vect) { // Interrupt is called once a millisecond, looks for any new GPS data, and stores it
char c = GPS.read();
if (GPSECHO) // if you want to debug, this is a good time to do it!
if (c) UDR0 = c; // writing direct to UDR0 is much much faster than Serial.print but only one character can be written at a time.
}

void useInterrupt(boolean v) {
if (v) {
OCR0A = 0xAF; // Timer0 is already used for millis() - we'll just interrupt somewhere in the middle and call the "Compare A" function above
TIMSK0 |= _BV(OCIE0A);
usingInterrupt = true;
} else {
TIMSK0 &= ~_BV(OCIE0A); // do not call the interrupt function COMPA anymore
usingInterrupt = false;
}
}

uint32_t timer = millis();

/*******
LOOP DA LOOP!
*******/
void loop()
{
//I'm using the interrupt, so I don't need the not using interrupt part here
if (GPS.newNMEAreceived()) { // if a sentence is received, we can check the checksum, parse it...
if (!GPS.parse(GPS.lastNMEA())) // this also sets the newNMEAreceived() flag to false
return; // we can fail to parse a sentence in which case we should just wait for another
}

if (timer > millis()) timer = millis(); // if millis() or timer wraps around, we'll just reset it

if (resetCounter){ //if I need to reset the value in EEPROM
EEPROM.write(address, 1); //set it to 1, so when you turn it on the next time, it's the first attempt
resetCounter = false; //don't reset it again though
}

if (millis() - timer > 2000) { // approximately every 2 seconds or so, check stuff
timer = millis(); // reset the timer

//now, I want to check to see whether or not I have a fix. If not, I want to run a piece of code
//that waits for a fix and turns off if I don't get one soon enough

if (GPS.fix){
if(lcdDebug){ //I want to know how long it took to get a fix, so I get an idea of what's going on
lcd.clear();
lcd.home();
lcd.print("It took (s)");
lcd.setCursor(0,1);
long seconds = timer/1000;
lcd.print(seconds);
delay(dlay); //wait until I can read it
}
//my checkDistance and checkDate functions return a distance (float) or a number of days (int). 0 means it's good, a number means I
//need to print something, because I'm not there yet
float myDistance = checkDistance(); //gives me my distance from destination
int myDate = checkDate(); //gives me the date from target date

if (myDistance == 0.0 && myDate == 0){
openBox(); //if I'm there, and it's time, open!
}
else{ //if not, then print the clues
lcd.clear();
lcd.home();
lcd.print(myDistance);
lcd.setCursor(0,1);
lcd.print("Miles");
delay(5000);
lcd.clear();
lcd.home();
lcd.print(myDate);
lcd.setCursor(0,1);
lcd.print("Days");
delay(5000);
turnOff(1); //turn off and increment the attempts
}
}
else{
initialization(); //this runs until a fix is found or the unit powers down
}
}

}

/**************
//this code waits for a fix and turns off if I doesn't get one soon enough
**************/
void initialization( void ){
//the first thing that I need to do is print out stuff for Lily to read, then I need to wait for a fix
//and if I don't get one soon enough, just power off.
//I can use timer, which is already an unsigned long
timer = millis();
if (firstOn == 0) {

//if this is the first time I've turned on, then I need to say hello
//first, I'm going to get how many attempts she's made
byte attempts = EEPROM.read(address);
lcd.clear();
lcd.setCursor(0,1);
lcd.print("Hello Lily");
lcd.home();
lcd.print("Attempt ");
lcd.print(attempts, DEC);
int attemptsLeft = maxAttempts - attempts;
delay(5000);
lcd.setCursor(0,1);
lcd.print(attemptsLeft);
lcd.print(" attempts left");
lcd.home();
lcd.print("Go outside");
delay(5000);
firstOn = 1;
}

if (firstOn == 1){ //if not, I'm calculating
lcd.clear();
lcd.setCursor(0,1);
lcd.print("Finding signal");
lcd.home();
lcd.print("Please wait");
firstOn++;
}

if (timer > waitTime) turnOff(0); //if I've waited to long, stop wasting battery and don't count it

//once I have a gps fix, then I can actually do the calculations. I've already got the lcd
//saying what I want, so go ahead and calculate stuff
}
/*********
Turns off everything
if it gets a 1, it turns off and increments the attempts. If it gets a 0, it turns off without incrementing attempts
if it gets anything else (like a 2), it will just say powering off and turn off
**********/
void turnOff(int attemptPlus){
//this will turn off my arduino. I don't know how this will happen yet, but it will happen for now,
//I'll just have it say that it's powering off

if (attemptPlus == 1){ //if I got a signal and am not in the right place, count the attempt
byte attempts = EEPROM.read(address);
attempts += attempts;
EEPROM.write(address, attempts);
}

if (attemptPlus == 0){
lcd.clear();
lcd.setCursor(0,1);
lcd.print("No signal");
delay(5000);
}

lcd.clear();
lcd.setCursor(0,1);
lcd.print("Powering off");
delay(5000);

//turn myself off with pololu switch
digitalWrite(offPin, HIGH);

//if I don't turn off, then I'm externally powered, and I want to open the box
delay(50);
openBox();

}

/********
Opens Box
********/

void openBox(void){
//this will open the box. I'll write this once I have motors wired up.
lcd.clear();
lcd.setCursor(0,1);
lcd.print("Opening Box");
digitalWrite(servoPin, HIGH);
delay(5000);
turnOff(2); //2 just makes it turn off

}

/*************************************************************************
//Function to check the distance from destination
//this returns 0 for there, or the distance away in miles
*************************************************************************/

float checkDistance( void ){
//I'm going to calculate the distance that I have between me and the target location using the haversine
//function. I got the function from the arduino forums
float gpsLat = NemaToDegrees(GPS.latitude);
float gpsLong = NemaToDegrees(GPS.longitude);
if (lcdDebug){
lcd.clear();
lcd.setCursor(0,1);
lcd.print("Latitude");
lcd.home();
lcd.print(gpsLat,6);
delay(dlay);
lcd.clear();
lcd.setCursor(0,1);
lcd.print("Longitude");
lcd.home();
lcd.print(gpsLong,6);
delay(dlay);
}

//I'm going to find the approximate distance and save it to miles away
float milesAway = calcdist( destinationLat , destinationLong , gpsLat , gpsLong);

//here I'm comparing the raw NEMA sentance instead of calculating the distance. This is more accurate, but does not
//give me how far I am away
float latCheck = abs(NemaDestinationLat - GPS.latitude);
float longCheck = abs(NemaDestinationLong - GPS.longitude);

if (lcdDebug){
lcd.clear();
lcd.setCursor(0,1);
lcd.print("Distance");
lcd.home();
lcd.print(milesAway,6);
delay(dlay);
lcd.clear();
lcd.setCursor(0,1);
lcd.print("LatCheck");
lcd.home();
lcd.print(latCheck,6);
delay(dlay);
lcd.clear();
lcd.setCursor(0,1);
lcd.print("LongCheck");
lcd.home();
lcd.print(longCheck,6);
delay(dlay);
}

if (latCheck < maxGPSAway && longCheck < maxGPSAway) return 0.0; //this checks the raw coordinates to see if I'm close enough

//now I'm going to check to see if I'm close enought to my destination using the distance
if (milesAway < maxMilesAway) return 0.0; //checks my distance to see if I'm close enough else{ //if I'm not there, return how far away I am return milesAway; } } /****************** //I'm calling these functions only if I have a fix //this is my function to check to see if I'm on the correct day //this returns 0 for I'm at/past the correct day (it can open after her birthday) //and returns the number of days to go if not *******************/ int checkDate( void ) { int gpsMonth = GPS.month; int gpsDay = GPS.day; //so, it looks like the GPS unit is on June 16, 2012 at 5:35 when I'm at June 15, at 10:37 pm //so it's either 7 hours ahead of me, or it's just a day ahead and the time is off. //I'm going to ignore this difference, and let her open the box early. Oh darn. if (lcdDebug){ lcd.clear(); lcd.setCursor(0,1); lcd.print("Month"); lcd.home(); lcd.print(gpsMonth); delay(dlay); lcd.clear(); lcd.setCursor(0,1); lcd.print("Day"); lcd.home(); lcd.print(gpsDay); delay(dlay); } if (gpsMonth > 9){ //October is month 10
//however, I'm one day ahead with this gps unit
return 0;
}
else{ //otherwise, I'm not there
//I need to calculate how many days I have to go
int daysLeft = 0;
//I'm giving this to her in August, so I just need to program it to count down from August to October
if (gpsMonth == 8){
if (serialDebug) Serial.println("August");
//I'm in August. I have 30 days in September, then the rest of August (31 days)
daysLeft = 30 + 31 - gpsDay + 1; //this should be the days left before October
}
else if ( gpsMonth == 7){
if (serialDebug) Serial.println("July");
daysLeft = 31 + 31 +30 - gpsDay + 1;
} //June = 30 days, July = 31 days, August = 31 days, September = 30 days
else{
if (serialDebug) Serial.println("September");
daysLeft = 30 - gpsDay + 1; //if it's not August, it's September, so subtract the day I'm at
}
return daysLeft;
}
}

/*************************************************************************
* //Function to calculate the distance between two waypoints
* //I got this from the arduino forums.
*************************************************************************/
float calcdist(float flat1, float flon1, float flat2, float flon2)
{
float dist_calc=0;
float dist_calc2=0;
float diflat=0;
float diflon=0;

//I've to spplit all the calculation in several steps. If i try to do it in a single line the arduino will explode.
diflat=radians(flat2-flat1);
flat1=radians(flat1);
flat2=radians(flat2);
diflon=radians((flon2)-(flon1));

dist_calc = (sin(diflat/2.0)*sin(diflat/2.0));
dist_calc2= cos(flat1);
dist_calc2*=cos(flat2);
dist_calc2*=sin(diflon/2.0);
dist_calc2*=sin(diflon/2.0);
dist_calc +=dist_calc2;

dist_calc=(2*atan2(sqrt(dist_calc),sqrt(1.0-dist_calc)));

dist_calc*=3958.76; //Converting to miles
//Serial.println(dist_calc);
return dist_calc;
}

/************
NEMA parser
Takes in the NEMA sentance values (degree.minutes) and outputs degrees
This is off by .3 miles (per calculation) due to the constraints of floats. a.k.a, I calculated it once, and I was off by
.3 miles. It may be more for other destinations.
*************/

float NemaToDegrees( float NemaValue ){
int NemaDegrees = NemaValue/100; //this gives me degrees
if (serialDebug){
Serial.println("Nema degrees Calculated");
Serial.println(NemaDegrees);
}
float NemaMinutes = (NemaValue - (float)NemaDegrees*100.0); //this gives me the minutes (positive value, since NemaValue is larger
if (serialDebug){
Serial.println("Nema Minutes Calculated");
Serial.println(NemaMinutes,4);
}
return (float)NemaDegrees + (NemaMinutes/60); //convert Minutes to degrees, add them, and return value
}

Feb 15

Laser Tag Update 2/15/15

So, about two years ago, I wanted to make a course to teach laser tag. I didn't make it a habit, and it didn't get done.

Now, I've made some progress towards that laser tag. However, like the me of the past, this is still a large project, and I haven't gotten very far.

So now, I'm going to (try to) use some of the advice I've got from Extra Credits. They make videos about video games, and their advice can be translated to other projects. I'm specifically talking about their series on making video games, and their rules video. I should refer to this every once in a while when I am unsure of what to do.

Completed Work

1. Create a program to send and receive tags
2. Build a prototype that can send and receive tags
3. Build a lens setup and test adding a lens - adding lens increased tag distance
4. Build LED test setup and increase current - increasing drive current increases tag distance
(Note: requires batteries that can supply the current, and capacitors)

In Progress

1. Increase range of tag unit send/receive

Methods:

In my meanderings across the internet, books and the like, I have come across information on optics. I haven't done very much with optics, so this is a lot of trial and error on my part. However, I do know that I want to collimate light. Basically, I want to take light from an LED (emanating at about 25 degrees) and turn it into a beam that travels straight. Fortunately, if you buy a lens, they tell you the focal length, or distance away that a collimated light source will be focused. Put a light source that far away, and presto, instant collimated light.

However, what assumptions are they making about that light source? In the land of physics, everything is a point source, meaning it doesn't have any height or width. I tried using a 1" diameter lens to collimate a 5mm diameter IR LED. I got it to transmit about 50 feet, but it did not work very well outside. When I checked what the beam looked like with a red LED, the beam was not a column, but focused a few inches from the lens. If I want my lens to work more like the theoretical column, I need to make my LED look more like a point source. That means a larger lens or a smaller LED. Why not try both?

Deliverable:

1. Get a larger lens/lenses 2"+ in diameter.
2. Build test set up and test 2" diameter lens (inside and outside) and record transmission distances at standard currents

Future work

1. Add more light indication.
2. Make tag unit more sturdy.

Dec 28

Sunrise Alarm Clock, Part 3

With the hardware built, now it's time to put hardware and software together. Using the tutorials mentioned in the previous post, I put together some code to read the time from the real time clock, tell the alarms library what time it is and use the alarms library to create an alarm to turn on the LED strip. I also added a button to turn off the lights (you could just reset the board, but now I have a button that I could use for other things).

Some notes on putting this together.

1. I think I accidentally destroyed digital pins 8 and 7 on the chip I'm using. They don't read anything in when I tried attaching a button to them. Oh well. I am now using pin 2 for a button.
2. I had the 12V power supply powering the arduino while having the arduino board (with the Atmega328p removed) connected to the board. The 5V from the arduino board was not connected to the breadboard, so I shouldn't be running power from my external power supply back into my usb hub. however, the grounds are electrically connected. This is probably sending some weird electrical noise back into my computer. This made my laptop turn off mysteriously and say that it had an error. I may be frying my usb hub. In the future, I should get some optocouplers to isolate my two circuits (my computer and the arduino) since I am using two power supplies (my computer's usb hub and the 12V power supply for the LED strip).

Dec 27

Sunrise Alarm Clock, Part 2

Welcome back. After designing the circuit using adafruit's lovely tutorials, the next step is to build it. I have attached a photo of what the circuit looks like in real life. A few points about why I chose to do certain things.

1. Wire Colors: Using different colors for different wires makes building your circuit and looking for problems much easier. I would suggest using differently colored wires for specific purposes. That way, when you look at your board, you know what wires are supposed to go where and can more easily identify problems. Here is the color scheme that I am using:
Red: I always use red wire for 5 Volt power. If it's red, I know that it's a 5V signal.
Brown: Brown wire is my 12 Volt power coming from my 12 Volt power supply.
Black: I normally use black wire for ground. In this case, I am not using negative voltage, so all black wires are ground.
White: I usually use white wire to transmit signals from the arduino and for my resonator.
Yellow/Green/Blue: This is a generic color for transmitting signals. Normally, as long as two adjacent signal wires are different colors, then it's ok. Normally, I use wires in (sort of) the following order: White/Yellow/Green/Blue. For this project, I chose green, yellow and blue to transmit the signals to my TIP120's so that I know what wires are going out to control each part of the RGB LED's. I can't use red as a signal wire, because I only use red for 5 Volt power.
Note: I didn't show the input power and the wires going to the RGB LED's in the picture below. There are, however, wires sticking up where I will put the RGB wires. The input power is unmarked, but has a brown wire on it already to remind me where it goes.

2. Resistors: I used 10 kOhm (10,000 Ohm) resistors for my button, and 1 kOhm (1,000 Ohm) resistors for my TIP120's. I do not need very much current for buttons, and the TIP120's do not need very much current to turn them on.

3. Capacitors: I used two capacitors for my voltage regulator. This helps to smooth out voltage spikes, which will occur as I turn the LED's off and on quickly. I used the capacitors that I had sitting around. Normally, I use the circuit described in Make: Electronics by O'Reilly. That has a 0.33 microFarad electrolytic capacitor on the input voltage and a 0.1 microFarad ceramic capacitor. If you are interested in learning about the basics of hardware, that is a great book to pick up. The capacitors I had were a little bigger, but it should work fine.

Sunrise Alarm Clock Breadboarded

Dec 17

Building a Sunrise Alarm Clock, 1

Sunrise Alarm Clock: 1

Have you ever woken up at 5:30 am to the most annoying sound on the planet? Yes, the sound that strikes fear in the most peaceful sleeper. The alarm clock sound. That dream crushing sound that jerks you back into reality. If only there was a smoother transition, one where I didn't wake up feeling angry that I was from my dreamscape so ungraciously taken. Enter the sunrise alarm clock.

Bill of Materials:

1. Arduino compatible (bare bones support for Atmega328p)

2. 12V 5A power supply (adafruit part number 352)

3. RGB LED strip (60 LED, adafruit 346)

4. TIP120 x3 (adafruit 976)

5. DS1307 Real Time Clock breakout board (adafruit 264)

Yes, I got a way beefier power supply than I needed. I could power a laptop off that thing. But then again, if I ever want more LED's, a motor, or a solenoid (hey, maybe I want my alarm clock to shoot socks at me in the morning out of my sock cannon? That'll wake me up.).

So, what is all this stuff and what does it do? Together, they make a sunrise alarm clock.

Adafruit has a lovely tutorial on hooking up the RGB LED strip here.

Adafruit has a wonderful tutorial on using the DS1307 real time clock here.

I'm using three PWM pins, 9, 10 and 11. 9 is connected to the green part of the RGB LED, 10 is red, and 11 is blue (see schematic). A diagram of what pins are what for the Atmega chip is shown on the arduino website: Atmega328 pin mapping.

If you follow the above Adafruit links, you will find everything you'd want to know on the parts. Now I need to wire it, code it, and test it.

Dec 07

Sunrise Alarm without a microprocessor, Cool password protected sketchbook, Mechanical Iris

Alrighty then. I came across a video on how to make a sunrise alarm clock using a timer, LED's, and capacitors for the fade in of the light. I thought it was cool, and may be an easier project than making one with an arduino. But then again, if I want to make my alarm clock wake me up with blue light, and put me to sleep with red light, then I'll want to control the color of my RGB LED's. But no matter, this is still a cool project.

Sunrise alarm clock (using passive components and a timer) video.

There was also a really cool password protected sketchbook video posted on adafruit. The video is here: Cool Password Protected Sketchbook. Is it really a password? No. It's a series of dials, buttons, and it even uses the door knock idea (there are many videos by now on knock door openers, you knock in a specific rhythm to open a door. Of all the one's I've seen, this one is the coolest. There's also a capacitive touch sensor version you can use on door knobs. I think some MIT video demonstrates that.). Anyway, this was cool.

Side Note: The link above for the garage door knock opener uses a mechanical iris as the surrounding structure. The DXF files for that are on page 2 of the following thread on the ShopBot forums. The link is here.

Oct 23

FTDI chips, a CNC Mill, Micro Arduinos and Hardware Confessions

Ok, I changed the order. But still. Here's some goings on in the outside world for inspiration.

The FTDI FT232 is (I guess) a very popular USB to serial converter. There's an article here about how windows made a driver to brick fake chips. Fun way to stop hackers, set their chips to "don't work."

This article is just titled like a hilarious joke from the past. It's called "What is This, A Microcontroller Board for Ants?" (Yep, Zoolander). It's about an ATiny85 board where the board is slightly bigger than the chip. Kudos for saving space (if I need a small arduino, I know where to go).

There is a MakerBot equivalent for a CNC machine. It's called Carvey. Article is here.

There is also a confessions of a hardware startup page. I haven't actually read it, so I do not condone what is said there. I will read it later and find it by posting it on my blog.