Welcome to the N1IR Electronics Website. Totally off the cuff, one take, unrehearsed video projects for anyone interested in amateur radio, electronic design, makers, hardware hackers and science.

Get off you duff and build something!
Training the hand and mind since 1982.

Friday, December 22, 2017

Project 12/15/17 50W x 50W Power Amp

The 50WX2 Stereo Power Amplifier. At 50 Watts per channel, the power amp kit costs less than the interconnects on many high end systems. Still, we find that many owners of $5,000+ systems use our kits for their second system. Why? To quote one student, “I put your amp up against my monoblocks…it wasn’t quite as good in some respects…but it was amazing how close it came. BTW, I had a blast putting the kit together!”

Why Build a Kit?

It's fun, relaxing, and educational. Completing a kit provides you with a great feeling of accomplishment, and we make complete kits that make it easy to build great sound. When you add your labor, you get high-end sound for a bargain price. The kits contain everything you need to build great looking, great sounding equipment. They have acclaimed assembly manuals with clear directions that produce first time success for 97% of the builders. Quick support makes the other 3% successful, too. We make great sounding, proven designs backed by knowledgeable support.

A special thanks to: 

Power Sources Unlimited, Inc. 
200 Stonewall Blvd., Ste, 4 Wrentham, MA  02093 

They are the company that donated the power supplies for this project.

 AMP and Power Supply

 Close up on PCB

AMP under dynamic testing

Thursday, December 21, 2017

Project Camping Candle

This project was designed and built by one of my seniors, we wanted to make a fake candle using LED's.

We came up with two LM555 astable multivibrator oscillators at two different frequencies and diode OR'ing the outputs to an blue LED, these two frequencies would beat together and cause the flickering effect you see on the video below. The student designed the circuit in GEDA and made a PCB using Protel to the T-Tech 5000 PCB Milling Machine.

This proved our rapid design process, the whole circuit form conception to working product was done in under 6 hours.

 PCB one of a kind proto type

Candle in action

Project 12/21/17 Digital Dice

Here is a project that my seniors are working on, Digital Dice. We used a 74LS193 Counter and a 74LS47 Decoder and a 74LS00 NAND Gate.

How it works. The counter counts from 1-6 and displays the count on the 7 segment display. So the first count starts at 0 and goes to 1,2,3,4,5,6 at count 7 the counter resets back to a pre-set condition of 1 then counts 2,3,4,5,6 on 7 resets back to the preset of 1 then counts 2,3,4,5,6 rinse cycle and repeat.

 Schematic on white board, Students will redraw this in GEDA and design a PCB in Protel

 Breadboard and testing

Here it is working

Wednesday, December 20, 2017

HVAC Repair

Here is a repair done by one of my 12th grade students, a Pipe Temperature Gauge. This was brought in non-working condition, we took it apart found some corrosion on the membrane switches on the PCB preventing the unit to turn on, cleaned and works great now. 

Here is the description on the company web site:

The Cooper-Atkins Model 4005i will measure pipe temperatures quickly and easily without a lot of equipment utilizing a claw type pipe clamp probe. Temperature registration is shown on a built-in digital LCD display. This unique instrument also allows measurements of liquids and solids with its retractable general-purpose probe hidden in the handle. Features include auto shut-off after 5 minutes of non-use, hold, max and min. The temperature range of this instrument is -20 ° to 300 °F (-29 ° to 149 °C). The Cooper model 4005i comes standard with a soft carry case including a belt loop so you can easily keep the instrument with you at all times.
It's the perfect tool to measure pipe surface temperatures and/or take measurements of liquids/solids quickly and easily without a lot of equipment with the same instrument. Patented Design. Can be used on pipes with diameters of 1/4" to 1-3/8". It features a cordless pipe clamp with a 2.5" retractable general purpose puncture probe. It includes a Nylon belt pouch.

Friday, December 15, 2017

Custom FM/MP3 Radio

Here is a project that one of my juniors did. He combined two kits and some speakers from a recycled TV to make a custom FM/MP3 Radio. Next week we plan on making a case with the Epilog Laser Cutter.

Here are the spec on the radio
1. With bluetooth audio receiver module, when cell phone and bluetooth module matching connection,the MP3 or nondestructive APE files via bluetooth sent to the product of the bluetooth receiver module to play,which has greatly helped the function of the product and entertainment.This product also be like ordinary MP3 decoder board,play U disk or TF card MP3 files,as well as the radio broadcast.(This product without bluetooth calling function,with no power amplifier,only connect to an external amplifier can it use)
2. Support signal switch directly.Support USB, TF
3. Support bluetooth (Bluetooth3.0 EDR) (after been paired with mobile phones can realize wireless music play)
4. Support USB/TF/Bluetooth/FM/LINE switch.MP3/WMA,WAV lossless music decoding chip.
5. Support USB/TF card switch,PREV,NEXT,fast forward,fast rewind,volume,EQ,play/pause,stop,single repeat,mute, shutdown and direct election.
6. Support Bluetooth PREV,NEXT,volume,EQ,play/pause,mute,turn it off.
7. Support FAT16,FAT32 file system.Support for MP1 Layer3,MP2 Layer3,MP3 Layer3 version of the song.Support 32-320 KBPS MP3 songs.
8. Support power off memory function: memory play songs and volume before power off.

Here are some links to the kits used:

Remote Control USB SD FM MP3 Player Module Bluetooth Audio Receiver Module

Sure Electronics AA-AK32111 Two Class AB Headphone Amplifiers 2x1W Kit

Tuesday, December 5, 2017

Project 12/8/17 Cable Tester

This weeks project for the sophomore class in shop is a CAT 5 Cable tester.

A cable tester is a device that is used to test the strength and connectivity of a particular type of cable or other wired assemblies. There are a number of different types of cable testers, each able to test a specific type of cable or wire. This one can be used for CAT 5, coaxial or any cable that has two conductors or more

The student breadboard and test the circuit our then mill out the PCB using a T-Tech 5000 PCB mill.

Project PCB and enclosure

Below is an example PCB CAD Design of the board

Friday, December 1, 2017

Project 12/1/17 Clock

Digital clock project, this is the same on featured at  


We made 8 clocks, students learned how to breadboard, mill a PCB and how to burn a ATMEGA328 using AVRDUDE.

Friday, November 24, 2017

Project 11/24/17 Fox and Hound Part 1

The Fox & Hound wire and cable tracing kit consists of a versatile Fox 2 tone generator (toner) and a high performance Hound inductive amplifier (probe). Featuring adjustable sensitivity, and Warble or Pulse tracer tone selector. Students learn breadboard, PCB milling, design and use a Epilog M2 Laser cutter to make a custom the enclosure made from 1/8 inch plywood.

Tune in soon for part 2 the Hound.

Student breadboard of the FOX Student Breadboard of the HOUND

 PCB mill design and final design

 Student cut enclosure using our Epilog Laser Cutter

Assembly of the FOX

Monday, November 20, 2017

TV Repair

Student repairing a LCD TV, TV was brought in form a teacher and the complaint was it did not turn on, below is a picture of what we found. Broken mains line, re soldered and up and working!

Friday, November 17, 2017

Project 11/17/17 TPS

Triple Power Supply Project

A must have in any laboratory, on a test bench, or for experimentation. This power supply is 3 variable power supplies in one unit. It features ±1VDC to ±15VDC at 2 Amps and 5VDC up to 5 Amps. 

Student learn the basics of linear voltage regulators (LM317/LM337), 16x2 Parallel loading LCD screens controlled by Arduino, bread-boarding, PCB design as well as custom enclosure design using our Epilog M2 laser cutter.

Also cover in this project is OPAMP signal conditioning using a LM324, Buffers, Inverting Amps and Dividers. Scaling, A2D conversion and math functions of the Arduino. 

Student finishing touches on TPS

Custom Enclosure using 1/4 inch Plywood

Tuesday, November 7, 2017

Arduino Clone

Find and test communications to chip

sudo avrdude -c usbtiny -p m328p

Erase Chip

sudo avrdude -c usbtiny -p m328p -e

Burn Main Hex file program

sudo avrdude -c usbtiny -p m328p -U flash:w:optiboot_atmega328.hex

Burn Fuses

sudo avrdude -c usbtiny -p m328p -U lfuse:w:0xFF:m -U hfuse:w:0xDE:m -U efuse:w:0x05:m

Friday, October 20, 2017

Scoreboard Fixed

One of our senior students troubleshot the scoreboard on the field today and found a faulty 1/4 inch TRS cable, Using a ohmmeter he ringed out the cable and found that the tip and ring were open from one end to the other. He then took it back to the shop and repaired the cable.

Picture of the broken cable, can you see the break in the wire?

Answer: No, this couldn't be seen visually, DMM is needed and the knowledge of how to use it.

Friday, September 29, 2017

Power Supply Fixed!

Students fix Power supply, for disabled amateur radio operator.

We were contacted by a local HAM radio operator that is blind about a power supply that runs his HF radio.

The power supply was a ASTRON 30 and did not function. The students were excited about taking on this job, we troubleshot the problem down to a faulty regulator and bad crowbar circuit protection. The student got to learn about transistor Voltage Regulator and Silicon Controlled Rectifier used a a over voltage crowbar protection circuit.

For more information about Handihams please visit the link below:


Inside the ASTRON 30

Big Linear Transformer


Picture of the bad regulator

Friday, July 7, 2017

Fast Charger for cell phone

Hi All,

Had a bunch of Traco Power TEN 20-2411WI hanging around so I decided to put them to good use, with a high current 20 Watt DC/DC converter. Input 9-36 VDC, Output 5 VDC at 4 A for my Raspberry PI 3.

Not designed of Apple Products

Data Sheet

Thursday, July 6, 2017

Echo-link Interface Box

Hi All,

Decided to finally get out of the prototype phase of my echolink interface. Here are some pics below of the project, it's been in use on the Plymouth repeater (146.685) for about 6 months with no issues. It took a little figuring out the RTS line on the FTDI cable was active low in stead of active high, but fixed it with a simple 2N7000 MOSFET inverter. The transformers are TY-145P and I used the ear bud/mic connector that came with the Beofeng UV-5R, I do believe that mouser now carries the spk/mic connectors for the kenwood, Beofeng, etc, etc.

Prototype Version 1

Here is the schematic

And finally the board design

Yes those are TO-39 Packages, hey they work good and come out great with the PCB mill machine, the flats side of the 2N7000 goes left toward the transformers. I have a better parts library but it's on my PC at work, go figure. I have the PCB file and Gerber's, email if needed.  

Sunday, April 30, 2017

Greetings Old Colony RVTHS,

Greetings Old Colony RVTHS,

Below is examples of our program

9th Grade Capstone Project
Line Following Robot Project - Design of a ultra fast line following robot project for student engineering technology project. Worked in conjunction with Electronics Engineering, Drafting and Precision Machine Technology provided a “canned” project. Robot would follow a black line (electrical tape) on the floor autonomously, via infrared led and infrared photo transistor. The engineering student program an algorithm in the Arduino. Students assemble the electronics and build a custom machined chassis and wheels. Students would “tune” the program to different track conditions.

10th Grade Capstone Project“Blimpy” Blue-tooth Controlled Blimp Project - Design of a ultra light modular control system for student engineering technology project. Worked in conjunction with Electronics Engineering, Drafting and Precision Machine Technology provided a “canned” project. Students assemble electronics and program the project, both in the Arduino IDE and a custom application on the cell phone using MIT APP inventor, scratch programming. Student would also design custom 3-d printed chassis in Solid Works
Online assembly instructions

(Exploratory Project) – A universal remote control allows you to turn virtually any TV On or OFF. We prefer OFF. You control when you see TV, rather than what you see. The TV-B-Gone remote is so small that it easily fits in your pocket so that you have it handy whenever you need it, wherever you go: airports, restaurants, laundromats, etc. TV-B-Gone is a type of Universal Remote Control which works by shining pulses of invisible light that tells most any TV to turn OFF or On.

Online assembly instructions

Exploratory Curriculumhttp://www.n1ir.com/p/exp2016.html
During our 5 day exploratory students build and take home ten unique projects. In an effort to reduce cost to the district I designed my own projects and documentation at a tenth of the cost of purchasing an off the shelf kit from a electronics supplier, Cost of my kits runs about $1.50 each.

        Resistor Triangle                       Resistor Square

        Resistor Cube                            Flashing LED

       Coin Decision Maker                Reaction Tester

        Insanity Alarm                          Continuity Tester

Example 11th Grade Curriculum Map

Related https://drive.google.com/open?id=0B4cPTBXMMjz9VjVmRjA2NkI0M3M

Shop https://drive.google.com/open?id=0B4cPTBXMMjz9VVBqQllodXZCS1U

Example Daily Lesson Plans

Related https://drive.google.com/open?id=0B4cPTBXMMjz9UTBsRU9oUlNieUE

Shop https://drive.google.com/open?id=0B4cPTBXMMjz9U1k5UlJRSjZuaDg

Please visit my You Tube Channel to see more projects and lessons
YOUTUBE Channel - https://www.youtube.com/user/chrisjohnson2003

Wednesday, April 26, 2017

2017 Scouts in the Sky! May 6 2017 - Plymouth Airport

2017 Scouts in the Sky! May 6 2017 - Plymouth Airport
The goal (or mission) of the camporee is to expose Scouts of all ages, to the world of aviation / aeronautics; from maintenance and flight to weather and air traffic control. If something has to do with aviation, then we hope to have it for the Scouts to enjoy. Patrols will participate in non-competitive activity stations and displays, filled with a wide variety of activities for Scouts to experience, learn from and enjoy. The program will revolve around, but not focus on, merit badges on Saturday. Aviation, Astronomy, Weather, and Radio Stations will be set up within the airport property for each participant to learn about Airplane Instruments, how to Pre-Flight a plane, learn Aerodynamics making Styrofoam Airplanes, build a Model Airplane, learn about Careers in Aviation, and work with a realistic Flight Simulator. A special event will be a free airplane ride provided by local certified volunteer pilots (subject to the weather). We are contacting affiliated organizations such as members of local model airplane clubs, Aircraft Owners and Pilots Association, and the local Civil Air Patrol to request help in this endeavor. We are in the planning stages, but these are the ideas we’re working on! As always, we will need volunteers to help assist with some of these activities. Plus, there will be a need for merit badge counselor volunteers to support the different merit badges.


// A fun sketch to demonstrate the use of the tone() function written by Brett Hagman.

// This plays RTTTL (RingTone Text Transfer Language) songs using the
// now built-in tone() command in Wiring and Arduino.
// Written by Brett Hagman
// http://www.roguerobotics.com/

// To play the output on a small speaker (i.e. 8 Ohms or higher), simply use
// a 1K Ohm resistor from the output pin to the speaker, and connect the other
// side of the speaker to ground.

// You can get more RTTTL songs from
// http://code.google.com/p/rogue-code/wiki/ToneLibraryDocumentation

//const int tonePin = 27;  // for rEDI board
const int tonePin = 13;  // arbitrary for arduino boards, set this to whatever you want


// These values can also be found as constants in the Tone library (Tone.h)
int notes[] = { 0,
262, 277, 294, 311, 330, 349, 370, 392, 415, 440, 466, 494,
523, 554, 587, 622, 659, 698, 740, 784, 831, 880, 932, 988,
1047, 1109, 1175, 1245, 1319, 1397, 1480, 1568, 1661, 1760, 1865, 1976,
2093, 2217, 2349, 2489, 2637, 2794, 2960, 3136, 3322, 3520, 3729, 3951

//char *song = "The Simpsons:d=4,o=5,b=160:c.6,e6,f#6,8a6,g.6,e6,c6,8a,8f#,8f#,8f#,2g,8p,8p,8f#,8f#,8f#,8g,a#.,8c6,8c6,8c6,c6";
//char *song = "Indiana:d=4,o=5,b=250:e,8p,8f,8g,8p,1c6,8p.,d,8p,8e,1f,p.,g,8p,8a,8b,8p,1f6,p,a,8p,8b,2c6,2d6,2e6,e,8p,8f,8g,8p,1c6,p,d6,8p,8e6,1f.6,g,8p,8g,e.6,8p,d6,8p,8g,e.6,8p,d6,8p,8g,f.6,8p,e6,8p,8d6,2c6";
//char *song = "TakeOnMe:d=4,o=4,b=160:8f#5,8f#5,8f#5,8d5,8p,8b,8p,8e5,8p,8e5,8p,8e5,8g#5,8g#5,8a5,8b5,8a5,8a5,8a5,8e5,8p,8d5,8p,8f#5,8p,8f#5,8p,8f#5,8e5,8e5,8f#5,8e5,8f#5,8f#5,8f#5,8d5,8p,8b,8p,8e5,8p,8e5,8p,8e5,8g#5,8g#5,8a5,8b5,8a5,8a5,8a5,8e5,8p,8d5,8p,8f#5,8p,8f#5,8p,8f#5,8e5,8e5";
//char *song = "Entertainer:d=4,o=5,b=140:8d,8d#,8e,c6,8e,c6,8e,2c.6,8c6,8d6,8d#6,8e6,8c6,8d6,e6,8b,d6,2c6,p,8d,8d#,8e,c6,8e,c6,8e,2c.6,8p,8a,8g,8f#,8a,8c6,e6,8d6,8c6,8a,2d6";
//char *song = "Muppets:d=4,o=5,b=250:c6,c6,a,b,8a,b,g,p,c6,c6,a,8b,8a,8p,g.,p,e,e,g,f,8e,f,8c6,8c,8d,e,8e,8e,8p,8e,g,2p,c6,c6,a,b,8a,b,g,p,c6,c6,a,8b,a,g.,p,e,e,g,f,8e,f,8c6,8c,8d,e,8e,d,8d,c";
//char *song = "Xfiles:d=4,o=5,b=125:e,b,a,b,d6,2b.,1p,e,b,a,b,e6,2b.,1p,g6,f#6,e6,d6,e6,2b.,1p,g6,f#6,e6,d6,f#6,2b.,1p,e,b,a,b,d6,2b.,1p,e,b,a,b,e6,2b.,1p,e6,2b.";
//char *song = "Looney:d=4,o=5,b=140:32p,c6,8f6,8e6,8d6,8c6,a.,8c6,8f6,8e6,8d6,8d#6,e.6,8e6,8e6,8c6,8d6,8c6,8e6,8c6,8d6,8a,8c6,8g,8a#,8a,8f";
//char *song = "20thCenFox:d=16,o=5,b=140:b,8p,b,b,2b,p,c6,32p,b,32p,c6,32p,b,32p,c6,32p,b,8p,b,b,b,32p,b,32p,b,32p,b,32p,b,32p,b,32p,b,32p,g#,32p,a,32p,b,8p,b,b,2b,4p,8e,8g#,8b,1c#6,8f#,8a,8c#6,1e6,8a,8c#6,8e6,1e6,8b,8g#,8a,2b";
//char *song = "Bond:d=4,o=5,b=80:32p,16c#6,32d#6,32d#6,16d#6,8d#6,16c#6,16c#6,16c#6,16c#6,32e6,32e6,16e6,8e6,16d#6,16d#6,16d#6,16c#6,32d#6,32d#6,16d#6,8d#6,16c#6,16c#6,16c#6,16c#6,32e6,32e6,16e6,8e6,16d#6,16d6,16c#6,16c#7,c.7,16g#6,16f#6,g#.6";
//char *song = "MASH:d=8,o=5,b=140:4a,4g,f#,g,p,f#,p,g,p,f#,p,2e.,p,f#,e,4f#,e,f#,p,e,p,4d.,p,f#,4e,d,e,p,d,p,e,p,d,p,2c#.,p,d,c#,4d,c#,d,p,e,p,4f#,p,a,p,4b,a,b,p,a,p,b,p,2a.,4p,a,b,a,4b,a,b,p,2a.,a,4f#,a,b,p,d6,p,4e.6,d6,b,p,a,p,2b";
char *song = "StarWars:d=4,o=5,b=45:32p,32f#,32f#,32f#,8b.,8f#.6,32e6,32d#6,32c#6,8b.6,16f#.6,32e6,32d#6,32c#6,8b.6,16f#.6,32e6,32d#6,32e6,8c#.6,32f#,32f#,32f#,8b.,8f#.6,32e6,32d#6,32c#6,8b.6,16f#.6,32e6,32d#6,32c#6,8b.6,16f#.6,32e6,32d#6,32e6,8c#6";
//char *song = "GoodBad:d=4,o=5,b=56:32p,32a#,32d#6,32a#,32d#6,8a#.,16f#.,16g#.,d#,32a#,32d#6,32a#,32d#6,8a#.,16f#.,16g#.,c#6,32a#,32d#6,32a#,32d#6,8a#.,16f#.,32f.,32d#.,c#,32a#,32d#6,32a#,32d#6,8a#.,16g#.,d#";
//char *song = "TopGun:d=4,o=4,b=31:32p,16c#,16g#,16g#,32f#,32f,32f#,32f,16d#,16d#,32c#,32d#,16f,32d#,32f,16f#,32f,32c#,16f,d#,16c#,16g#,16g#,32f#,32f,32f#,32f,16d#,16d#,32c#,32d#,16f,32d#,32f,16f#,32f,32c#,g#";
//char *song = "A-Team:d=8,o=5,b=125:4d#6,a#,2d#6,16p,g#,4a#,4d#.,p,16g,16a#,d#6,a#,f6,2d#6,16p,c#.6,16c6,16a#,g#.,2a#";
//char *song = "Flinstones:d=4,o=5,b=40:32p,16f6,16a#,16a#6,32g6,16f6,16a#.,16f6,32d#6,32d6,32d6,32d#6,32f6,16a#,16c6,d6,16f6,16a#.,16a#6,32g6,16f6,16a#.,32f6,32f6,32d#6,32d6,32d6,32d#6,32f6,16a#,16c6,a#,16a6,16d.6,16a#6,32a6,32a6,32g6,32f#6,32a6,8g6,16g6,16c.6,32a6,32a6,32g6,32g6,32f6,32e6,32g6,8f6,16f6,16a#.,16a#6,32g6,16f6,16a#.,16f6,32d#6,32d6,32d6,32d#6,32f6,16a#,16c.6,32d6,32d#6,32f6,16a#,16c.6,32d6,32d#6,32f6,16a#6,16c7,8a#.6";
//char *song = "Jeopardy:d=4,o=6,b=125:c,f,c,f5,c,f,2c,c,f,c,f,a.,8g,8f,8e,8d,8c#,c,f,c,f5,c,f,2c,f.,8d,c,a#5,a5,g5,f5,p,d#,g#,d#,g#5,d#,g#,2d#,d#,g#,d#,g#,c.7,8a#,8g#,8g,8f,8e,d#,g#,d#,g#5,d#,g#,2d#,g#.,8f,d#,c#,c,p,a#5,p,g#.5,d#,g#";
//char *song = "Gadget:d=16,o=5,b=50:32d#,32f,32f#,32g#,a#,f#,a,f,g#,f#,32d#,32f,32f#,32g#,a#,d#6,4d6,32d#,32f,32f#,32g#,a#,f#,a,f,g#,f#,8d#";
//char *song = "Smurfs:d=32,o=5,b=200:4c#6,16p,4f#6,p,16c#6,p,8d#6,p,8b,p,4g#,16p,4c#6,p,16a#,p,8f#,p,8a#,p,4g#,4p,g#,p,a#,p,b,p,c6,p,4c#6,16p,4f#6,p,16c#6,p,8d#6,p,8b,p,4g#,16p,4c#6,p,16a#,p,8b,p,8f,p,4f#";
//char *song = "MahnaMahna:d=16,o=6,b=125:c#,c.,b5,8a#.5,8f.,4g#,a#,g.,4d#,8p,c#,c.,b5,8a#.5,8f.,g#.,8a#.,4g,8p,c#,c.,b5,8a#.5,8f.,4g#,f,g.,8d#.,f,g.,8d#.,f,8g,8d#.,f,8g,d#,8c,a#5,8d#.,8d#.,4d#,8d#.";
//char *song = "LeisureSuit:d=16,o=6,b=56:f.5,f#.5,g.5,g#5,32a#5,f5,g#.5,a#.5,32f5,g#5,32a#5,g#5,8c#.,a#5,32c#,a5,a#.5,c#.,32a5,a#5,32c#,d#,8e,c#.,f.,f.,f.,f.,f,32e,d#,8d,a#.5,e,32f,e,32f,c#,d#.,c#";
//char *song = "MissionImp:d=16,o=6,b=95:32d,32d#,32d,32d#,32d,32d#,32d,32d#,32d,32d,32d#,32e,32f,32f#,32g,g,8p,g,8p,a#,p,c7,p,g,8p,g,8p,f,p,f#,p,g,8p,g,8p,a#,p,c7,p,g,8p,g,8p,f,p,f#,p,a#,g,2d,32p,a#,g,2c#,32p,a#,g,2c,a#5,8c,2p,32p,a#5,g5,2f#,32p,a#5,g5,2f,32p,a#5,g5,2e,d#,8d";

void setup(void)

#define isdigit(n) (n >= '0' && n <= '9')

void play_rtttl(char *p)
  // Absolutely no error checking in here

  byte default_dur = 4;
  byte default_oct = 6;
  int bpm = 63;
  int num;
  long wholenote;
  long duration;
  byte note;
  byte scale;

  // format: d=N,o=N,b=NNN:
  // find the start (skip name, etc)

  while(*p != ':') p++;    // ignore name
  p++;                     // skip ':'

  // get default duration
  if(*p == 'd')
    p++; p++;              // skip "d="
    num = 0;
      num = (num * 10) + (*p++ - '0');
    if(num > 0) default_dur = num;
    p++;                   // skip comma

  Serial.print("ddur: "); Serial.println(default_dur, 10);

  // get default octave
  if(*p == 'o')
    p++; p++;              // skip "o="
    num = *p++ - '0';
    if(num >= 3 && num <=7) default_oct = num;
    p++;                   // skip comma

  Serial.print("doct: "); Serial.println(default_oct, 10);

  // get BPM
  if(*p == 'b')
    p++; p++;              // skip "b="
    num = 0;
      num = (num * 10) + (*p++ - '0');
    bpm = num;
    p++;                   // skip colon

  Serial.print("bpm: "); Serial.println(bpm, 10);

  // BPM usually expresses the number of quarter notes per minute
  wholenote = (60 * 1000L / bpm) * 4;  // this is the time for whole note (in milliseconds)

  Serial.print("wn: "); Serial.println(wholenote, 10);

  // now begin note loop
    // first, get note duration, if available
    num = 0;
      num = (num * 10) + (*p++ - '0');
    if(num) duration = wholenote / num;
    else duration = wholenote / default_dur;  // we will need to check if we are a dotted note after

    // now get the note
    note = 0;

      case 'c':
        note = 1;
      case 'd':
        note = 3;
      case 'e':
        note = 5;
      case 'f':
        note = 6;
      case 'g':
        note = 8;
      case 'a':
        note = 10;
      case 'b':
        note = 12;
      case 'p':
        note = 0;

    // now, get optional '#' sharp
    if(*p == '#')

    // now, get optional '.' dotted note
    if(*p == '.')
      duration += duration/2;

    // now, get scale
      scale = *p - '0';
      scale = default_oct;

    scale += OCTAVE_OFFSET;

    if(*p == ',')
      p++;       // skip comma for next note (or we may be at the end)

    // now play the note

      Serial.print("Playing: ");
      Serial.print(scale, 10); Serial.print(' ');
      Serial.print(note, 10); Serial.print(" (");
      Serial.print(notes[(scale - 4) * 12 + note], 10);
      Serial.print(") ");
      Serial.println(duration, 10);
      tone(tonePin, notes[(scale - 4) * 12 + note]);
      Serial.print("Pausing: ");
      Serial.println(duration, 10);

void loop(void)

Tuesday, April 25, 2017

DIY USB password generator Project

sudo avrdude -c usbtiny -p t85

sudo avrdude -c usbtiny -p t85 -U flash:w:main.hex

sudo avrdude -c usbtiny -p t85 -U lfuse:w:0xe1:m -U hfuse:w:0xdd:m

below is from http://codeandlife.com/2012/03/03/diy-usb-password-generator/
this is a repost

Having done half a dozen V-USB tutorials I decided it’s time to whip up something cool. As USB keyboards were an area untouched, I decided to make a small USB HID keyboard device that types a password stored in EEPROM every time it’s attached. A new password can be generated just by tabbing CAPS LOCK a few times (4 times to start password regeneration and one tab for each password character generated, 10 is the default password length). Below you can see the device in action:
The place I work at requires me to change my password every few months so this would be one way to skip remembering a new password altogether (as long as I remember to write it down before regenerating a new one so password can be changed :).

What is inside?

The device is powered with a simplified version of the hardware I used in my ATtiny85 USB tutorial – I stripped away the LCD, reset pullup and both capacitors. If you’re better in cramming components inside enclosures I suggest adding at least a 0.1 uF capacitor between VCC and GND, but it seems to work fine even without it:

The enclosure was graciously donated by an old 512 MB flash drive. I couldn’t make myself to break the USB connector from the circuit board inside, so I stripped appart a short USB cable instead (shown on left):

After some thinking and iterative soldering, I managed to cram everything on a tripad veroboard with 2×8 pads with the following initial setup:

I soldered the connector first, then the zener diodes, then resistors and jumpers, and finally VCC, GND and the ATtiny itself. I used the following tricks to make all ends meet:
  • D+ zener diode goes to the pad under ATtiny that is connected to GND pin
  • After the D- zener diode, only 1 pad is left for 2k2 pullup and 68 ohm resistor, so I used a jumper wire to the next pad
  • 2k2 pullup goes to a pad connected to ATtiny VCC
  • VCC goes to the pad under the ATtiny using a black jumper wire
  • I soldered the D+ 68 ohm resistor to a wrong tripad, so I used another jumper wire just barely visible behind the top left black jumper wire for GND
I was pretty satisfied the result and the fact that it actually worked! The board did not initially fit into the very snug space in the plastic enclosure, so I had to use a Dremel to trim its insides a bit, but after that, everything snapped right back (click for larger versions):

Update: For those who are building this project – I recommend you first build it on a breadboard, and only when you have it working, solder it to a veroboard. Here are two additional, extra-large pictures of the configuration I used to help you in the component layout:


The device presents itself to the computer as a USB HID keyboard. To enable communication to the device, it is a boot-compliant keyboard that can receive LED status changes from the computer. HID descriptor is from Frank Zhao’s USB business card example and I also looked at Frank’s code to understand how LED state is sent to the device (in short, PC sends a control message with 1 byte of data, the LED state bit mask).
The code is mostly based on my USB HID mouse example except for the usbsconfig.h and HID descriptor changes required to implement a boot keyboard. Update: You may also want to read my USB HID keyboard post if you want to learn more. I’ve documented the code but here are some highlights if you want to understand it better:
  • PASS_LENGTH defined in the beginning controls the length of generated passwords
  • SEND_ENTER can be defined to 1 if you want the device also to send ENTER after typing the keyboard
  • measuring_message and finish_message contain the messages that are displayed when generating / saving a new password
  • buildReport() is called by the program main loop to send keypresses to PC one by one – it translates characters in messageBuffer to USB key codes on the fly
  • usbFunctionWrite() is implemented to receive the 1-byte LED state from PC – it calls caps_toggle() function every time the LED state changes
  • generate_character() is used to return random keypresses – it is currently written to return alphanumerics, hyphen and underscore (64 symbols make it simple to select one so each has equal chance of being selected without additional logic)
  • caps_toggle() does the caps-lock counting and password generation/saving
I’ve packed the source files with the schematic, critical pictures and a Makefile. In addition to “make flash” you of course need to update the fuse bits to use the PLL clock source – see details from my previous tutorial for that. I also very strongly recommend testing the device using a breadboard before soldering it, because otherwise reflashing will be a major pain.
And of course, if you build it, try it at your own risk – and remember that once you reprogram the password, nothing will be able to restore it. I recommend storing passwords generated with the device to a safe place just to be sure.

Update: Getting it from SparkFun

I found out yesterday that SparkFun is carrying an almost identical piece of hardware, the AVR Stick. So if you order one and reprogram it with this firmware (pin configuration in usbconfig.h needs to be updated in that case), you can avoid some soldering (although not all, you’ll likely need to solder in the programming header).
I asked SparkFun if they’d be interested to make a “2.0” model of their AVR Stick with actual USB connector and enclosure to go with the package, and my password generation firmware preloaded. If you think that’s a good idea, now would be a great time to send them feedback. I’d also be interested in covering additional hacks and tutorials with such a device. :)

Update 2: Indiegogo project

Alvin Chang is currently (December 1st 2012) running a Indiegogo project to build a device very similar (and inspired by) my DIY version. In case you’re interested in getting a ready-made version, be sure to check Mr. Chang’s project out: Aladdin: The Key to Your Computer.