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.

Saturday, December 21, 2013

EEWeb.com

Just got an email a couple of weeks ago introducing me to this site. Check out the link below on the right. I'm really impressed I am still going though it all there is so much information. Go check it out, thanks Algen for the great site.

Baofeng UV-5R Charger Modification

Hi all,
I've had my Baofeng UV-5R for a few months now and wanted to charge from my camper and car. Unfortunately I noticed the input voltage for the charger was 10 Volts DC in, very strange. Usually Chargers operate from 12VDC, so off to the internet I went.

I took the charger apart and found one IC (hxn-ws), so I tried finding the datasheet but could not, usually in the data-sheet it would give me the max voltage that I could apply in the specs.

Rather than risk the charger and put too much voltage and possibility blow the charger IC I decided  to place a linear regulator in. All I had on hand were some LM7805 and 5.1 Volt Zener so I came up with this.



By using this circuit my charger can now safely operate from 10-35VDC Input, at only 400mA max current the LM7805 is overkill. This was an easy mod drilling only three holes and scraping some solder resist off.












Thursday, December 19, 2013

Fall semester is over

Just finished CSC1050 at FSU, I should be ramping up the post and a few days.

Thursday, November 28, 2013

Turkey Day Shoot Out

Had some extra time before T-Day Dinner so I designed and bread boarded some circuits. Remember all of those LM324 we got donated, here are a few new projects for my students.


Here is a Freezer Alarm Circuit that uses a thermistor, a simple comparator. Tested and protoboard, PCB comming soon!

Alien Warbot, Scoots around with a vibrating motor when a IR signal from a remote is received. Tested and protoboard, PCB comming soon!

Laser Target, Hit the target with a laser pointer and an alarm beeps. Hook it up to a solid state relay and turn on a light.Tested and protoboard, PCB comming soon!

Simple Temperature Alarm / Controller, for cooling or heating. Tested and protoboard, PCB comming soon!


I also tried out software called Fritzing, tried it with a simple arduino project. It was pretty intuitive but the PCB had something to be desired, very limited options on trace size. I use 80  mil for all traces and the max was 48 mil.


Unfortuanlly I only had four hours to to this, all of the circuits work and were prototyped and worked, but the PCB will have to wait until another day.





Monday, November 11, 2013

Replacement Project, Musical PIC PART 3

Here is the PCB design



Below is a video of the competed project playing Zelda RTTL (Ring Tone Transfer Language)

Friday, October 25, 2013

Replacement Project, Musical PIC PART 2

Well just finished the replacement  Musical PIC project, used a ATMEGA328, I know, I know, it's over kill but I've got over 600 of them in stock in the shop. I used the Arduino IDE and the TONE library.


One problem I ran into was the newest Arduino 1.0.5 did not work with the old TONE library, it got stuck on wiring.h in the TONE.CPP file, just change In \libraries\Tone\Tone.cpp change #include <wprogram.h> to #include <arduino.h> 


and bingo work again. I also used the rttl example program that came with the libary. This you can find any RTTL ring tone and use it, the example program come with about 20 or so songs, all you have to do is remove the comment // to the song you would like to burn on the IC.





Below is a schematic 






PCB Design Coming Soon !!!

If you refer to the schematic, there is no ICSP pins. You must use the Arduino platform first and program then remove the IC and place it in the newly programmed Arduino IC on to the PCB you just made.

Once this is done simply get a new ATMEGA328P-PU and burn a boot-loader using Adafruits USBtinyISP programmer. This eliminates the need to buy a new Arduino platform at $30, all you are doing is replacing the IC with the newly burned IC with boot-loader at around $1.00 each.

It's important to use the ATMEGA328P-PU version, the ATMEGA328-PU has a different chip Hex ID. You can still use the -PU IC but you have to change the embedded AVRdude Utility in the Arduino IDE and change the ID to fool the Arduino IDE to burning the boot-loader. 

What's the difference between the ATMEGA328P-PU version and the ATMEGA328-PU, not much the P-PU has a micro current sleep mode.

Notes:
I deleted the two 22pf caps hanging off the crystal to make the project cheaper and used a 200 ohm resistor to limit the current to the 8 ohm speaker. This eliminated the need for a driver transistor. 

Overall cost of the project

Speaker = Free from donation (we have over 400 new 2" SPK)
ATMEGA328 = $1.00 in bulk
Resistor = less that $0.01
Xtal = $0.50
PB SW = Free from donation (we have over 5000 in stock)

If you were to buy from digikey or jaycar it would probably be under $5 USD

Replacement Project, Musical PIC PART 1

Well one of our staple project for our fresmen bit the dust. It was called the Musical PIC. The problem was I had a invalid HEX file, checksum error for some reason.

Back 5 years ago it was great project but it had a few drawbacks. First it used a PIC12C508 OTP. Yep One Time Programmable, what a pain in the a$$ if you need to change code. Burn change, burn change and rinse and repeat till you get it right, meanwhile at $0.50 a chip development of anything got expensive. Second I only had a couple of songs, I'm not musically inclined so figuring out songs to assembly language (ASM) was a real pain.

Well here is the original article with the 12C508.

A very simple PIC project to try. With the basic program available to download below you can insert any tune you like. My three year old son likes this Teletubbies tune. With a little more circuitry I wired it to the door of the car. Everytime he closed the door the car plays the Teletubbies tune. It was wired from the 0V of the car body to the wire that connects to the door switch. When the door is opened the supply to the PIC is shorted. When the door is closed the supply is reinstated and the PIC restarts its program again. Alternately it could be powered off batteries and hidden inside a childs toy.
 Hex code
:020000040000FA
:100000002500490A540855084E0845082008560896
:1000100031082E0830080B02E2016808C208010806
:100020006808960800087F08F60800086808DE08D7
:1000300005085E0898080208770827080608680877
:10004000580802087F08C40805088D08ED0806084E
:100050006808C20801086808960800087F08F608C2
:1000600000086808DE0805085E08F20801085E0856
:10007000A60800087708060801085E087E0806083A
:100080006808B10804085408D00805085008350865
:100090000C082A0C2600400006006B005809620973
:1000A0003C0C8B0043074E0AFF0C06000300490A74
:1000B0000B092700AB020B092800AB020B09290032
:1000C000AB020008A90207026B096602E802630A94
:1000D000E902630A00082A00000000000000000096
:0800E0000000EA026C0A0008AE
:021FFE00EA0FE8
:00000001FF


ASM File
; FILE            TUNE.ASM
; FOR            12C508A
; CLOCK       Internal

    TITLE "TUNE Program"
    LIST P=12c508a
    include p12c508a.inc

    ;config settings for PICSTART Programmer
    __CONFIG _IntRC_OSC & _CP_OFF & _WDT_OFF & _MCLRE_OFF  

    constant noteLG    =.159        ;G note constants
    constant noteA    =.141        ;A
    constant noteB    =.127        ;B
    constant noteC    =.119        ;C
     constant noteD    =.104        ;D
    constant noteE    =.94        ;E
    constant noteFS    =.84        ;F#
    constant noteG    =.80        ;G

    constant MINIM =.250000        ;note length constants
    constant SEMIN =MINIM/2
    constant CROTCH =SEMIN/2
    constant QUAVER =CROTCH/2
    constant SEMIQV =QUAVER/2

NOTE    macro freq,length
    retlw freq
    retlw low ((length) / freq)
    retlw high ((length) / freq)
    endm

    ;File registers
    org 7
freq    res 1
len    res 1
lenh    res 1
frq    res 1
tabpos    res 1

    org 0
    movwf OSCCAL
    goto start

    retlw 'T'    ;chip identification
    retlw 'U'
    retlw 'N'
    retlw 'E'
    retlw ' '
    retlw 'V'
    retlw '1'
    retlw '.'
    retlw '0'

tune    movf tabpos,w
    addwf PCL,f

    ;example tune
 
tunest     
    NOTE noteC,CROTCH    ;1

    NOTE noteD,CROTCH    ;2

    NOTE noteF,QUAVER    ;3

    NOTE noteE,QUAVER    ;4

    NOTE noteD,QUAVER    ;5

    NOTE noteC,CROTCH    ;6

    NOTE noteG,CROTCH    ;7
     
    NOTE noteF,QUAVER    ;8

    NOTE noteE,QUAVER    ;9

    NOTE noteD,QUAVER    ;10
     
    NOTE noteC,CROTCH    ;11

    NOTE noteG,CROTCH    ;12
     
    NOTE noteF,QUAVER    ;13

    NOTE noteE,QUAVER    ;14

    NOTE noteF,QUAVER    ;15
     
    NOTE noteD,QUAVER    ;16
     

endtab                ;end of tune

start    movlw b'00101010'    ;set outputs
    movwf GPIO
    clrw 
    tris GPIO        ;GPIO all outputs
    clrf tabpos        ;reset table position
nxtnote    call getnote         ;get note from table
    call play        ;play note
    movlw endtab - tunest    ;check if at end
    subwf tabpos,w        ;of table
    btfss STATUS,Z
    goto nxtnote        ;no then get next note
     
    movlw b'11111111'    ;set outputs to high
    tris GPIO        ;impedence input mode
    sleep            ;put PIC in low power mode
    goto start        ;re-start if woken up

getnote    call tune        ;get note from table
    movwf freq
    incf tabpos,f
    call tune        ;get length lower byte
    movwf len
    incf tabpos,f
    call tune        ;get length high byte
    movwf lenh
    incf tabpos,f
    return

play    incf lenh,f
play2    movf freq,w
    call note        ;wait 1/2 frequency
    comf GPIO,f        ;toggle sounder
    decfsz len,f
    goto play2        ;keep looping until
    decfsz lenh,f        ;note finished
    goto play2
    return     

note    movwf frq        ;wait 1/2 of frequency
wait    nop                     
        nop
    nop
    nop
        nop
        decfsz frq,f
        goto wait
        return 

    end


Thursday, October 24, 2013

This old arcade console

Got an old arcade console in the other day. Totally dead, found a bad switching power supply. Believe it or not power consumption to the CPU board is very small at about 25 watts, surprising considering all the logic is discreet 74XX series. This was a donkey con knock off. Here are some pics

 Replacement SMPS, notice the isolation transformer in the center, 
the original was totally burnt up with heat damage.

Console Front

Inside cabinet, in fact one of the RAM IC was decapped and still working


 Close up of CPU board, two large MSI chips one for sound and one main CPU, tons of ROMS and standard 74XX series logic


November 1981


Thursday, October 17, 2013

November General Course, HAM Radio


The General Course for November is a go! If you know anyone who is interested in taking the General Course please pass this on. Thanks to all that volunteer without your effort the hobby and this class would not be a success.

Call out to volunteer instructors, anyone wish to teach a section please email me.

Location: Plymouth Airport

Sunday November 17 ; 8AM to 4PM (elements run roughly 1.5 hours)
8:00-9:30 G1 – Commission’s Rules (N1IR, Chris)
9:30-11:00 G2 – Operating Procedures (KB1EVY, John)
11:00-12:30 G3 – Radio Wave Propagation (OPEN)
12:30-1:00 Lunch (30-45 min)
1:00-2:30 G4 – Amateur Radio Practices (Mike B.)
2:30-4:00 G5 – Electrical Principles (N1IR, Chris)

Sunday November 24 ; 8AM to 4PM
8:00-9:30 G6 – Circuit Componets (N1IR, Chris)
9:30-11:00 G7 – Practical Circuits (N1IR, Chris)
11:00-12:30 G8 – Signals and Emissions (OPEN)
12:30-1:00 Lunch (30-45 min)
1:00-2:30 G9 – Antennas (Mike B.)
2:30-4:00 G0 – Electrical and RF Safety (KB1SRO, Judy)

Testing Sunday November 24 4pm to 5pm Enrollment
VE's:
N1IR
KB1SRO
KB1EVY

Student Roster:
Kb1WWV Bob

Thank for you support
CJ, N1IR

October Update

Hello all,

Sorry things have been busy lately. I'm taking an online course at Fitchburg State CSC 1050 Internet Communications and learning a lot. Believe it or not this is my first "real" college course in computers. I've been into computers since my first PC back in 1982 the IBM 5150 (8088) and have been self taught with computers since. I'm and old DOS guy but worked with all windows from windows 286 up to now Windows 8 and switched over to linux since Ubuntu 8, never going back to windows again, lol. 

For those of you who need to feel nostalgic check out http://www.youtube.com/watch?v=JnSz-Hb9LQY BBS the documentary. I actually owned and ran a BBS myself back in the early 90's and my number was 617 826 7134. I still run a radio packet station with ham radio at 1200 baud and connect to the N1RCW Packet BBS

Well enough ranting got to get back to work.



Thursday, September 26, 2013

How to Burn ATTINY85 with USBtiny and Ubuntu


How to Burn ATTINY85 with USBtiny and Ubuntu



Find and test communications to chip

sudo avrdude -c usbtiny -p t85



Erase Chip

sudo avrdude -c usbtiny -p t85 -e




Burn Main Hex file program

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




Burn Fuses

sudo avrdude -c usbtiny -p t85 -U lfuse:w:0xfd:m -U hfuse:w:0xdf:m

Sunday, August 25, 2013

Don't cheap out on your receptacles

Just replaced an receptacle outlet in my brother in-laws house, one of the $0.50. Lesson learned don't use cheap outlets, spend the extra couple of bucks for a seymour or name brand receptacle, this was on a GFCI branch as well and never triped.







Tuesday, August 20, 2013

Echolink Microphone Interface (Kenwood MC-58)

Hello all, I was using Echolink and my PC headset mic failed so I wired up a Kenwood MC-58 to have more of a radio feel to Echolink. I'm using Echolink via WINE on Ubuntu 12.
 

Here is the schematic,


I used the CTS line on the RS-232 (yes my new PC still has a hard-wire RS-232, you can still get them on Lenovo) I haven’t tried a USB to 232 converter but it should work in windows, wine in Linux doesn’t support them. The only thing I wish was a way to force RTS high via echolink, this would eliminate the need for a battery.

PIC of the setup



Video




Pitfalls:


5 V from USB port, I tried this too much noise, tons of noise over mic

V+ from Mic port, voltage to low only 2.5V could not trip CTS pin all the time.


Yeasu Mic (MH-45), for some reason they use a transistor output on PTT line ???






Thursday, August 15, 2013

Phase angles in RLC circuit who is ELI the ICE man?

Here is a video I shot on how to solve phase angles in RLC for the EXTRA amateur radio exam.

Remember:

RISE/RUN * ARC SIN


XL
|
|
|
------------R
|
|
|
XC



Thursday, August 8, 2013

Modding the FIOS Motorla DCT700/US for Remote IR

Hello All,

Just upgraded from Comcast to FIOS. Unfortunately the Motorla DCT700 STB (set-top-box) does not have a remote IR receiver, so we are going to mod the STB to accept a hard-wire remote IR receiver.




Here is the original Comcast STB, notice the IR in

Here is the FIOS STB (Motorla DCT700)

The MOD is pretty easy we are just putting another IR receiver module in parallel with the original, here is the IR Receiver data sheet for the Motorla DCT700

Labeled V32238 aka TSOP32238
http://www.vishay.com/docs/82489/tsop322.pdf

Here is the mod

Green wire = Ground = Shield
Blue wire = +VS = Tip
Orange = Data pin = Ring
Carrier Frequency 38 Khz


The "DTA DIGITAL TRANSPORTER ADAPTER IR EMMITER 3.55MM"

Or you can make your own cable at radio shack.
http://www.radioshack.com/product/index.jsp?productId=2049727


ALL DONE ENJOY!

There is a already small hole for the wires, I can just go in and remove everything when returning the STB.










Saturday, July 13, 2013

ATTIny85 Basic Combo Lock

Today I made a simple 4 button combo lock of a shed, I would like to thank Tanner Ewing for the original code. I've changed it to work on a ATTINY85 and eliminated the kill switch, a reset switch is optional for a 5th button but I wanted to make this as minimal as possible. With a little bit more code you can put a retry limit and lock it out for x amount of time after so many retries. Also you can extend the number of button pushes or even have double taps to make the combo more complex. I also can open the shed with a key so if there is an issue with power I can still get in.





ATTIny85 Basic Combo Lock


ATTIny85 Basic Combo Lock Code:
*************************************************************
 EXAMPLE 1
/*
Basic Combo Lock password 1234

N1IR - Chris Johnson
email: n1ir@arrl.net

Arduino 1.0 IDE using ATTINY85
http://hlt.media.mit.edu/?p=1695

Pin 1 = RESET  Pin 8 = VCC
Pin 2 = PB3    Pin 7 = PB2
Pin 3 = PB4    Pin 6 = PB1
Pin 4 = Gnd    Pin 5 = PB0

Work Cited
http://www.electronics123.com/s.nl/it.I/id.30/.f

*/

// set pin numbers:
const int buttonPin1 = 0; // Pin 5 = PB0
const int buttonPin2 = 1; // Pin 6 = PB1
const int buttonPin3 = 2; // Pin 7 = PB2
const int buttonPin4 = 3; // Pin 2 = PB3
const int RelayPin =  4;  // Pin 3 = PB4

// variables will change:
int buttonState1 = 0;         // variable for reading the pushbutton status
int buttonState2 = 0;
int buttonState3 = 0;
int buttonState4 = 0;
int combCheckSum = 0;

void setup() {
 
  pinMode(RelayPin, OUTPUT);  // initialize the LED pin as an output:   
  pinMode(buttonPin1, INPUT); // initialize the pushbutton pin as an input:
  pinMode(buttonPin2, INPUT);
  pinMode(buttonPin3, INPUT);
  pinMode(buttonPin4, INPUT);
  // initialize the pushbutton pin as an input:
}

void loop(){
  // read the state of the pushbutton value:
  buttonState1 = digitalRead(buttonPin1);
  buttonState2 = digitalRead(buttonPin2);
  buttonState3 = digitalRead(buttonPin3);
  buttonState4 = digitalRead(buttonPin4);

 if (buttonState1 == LOW) {    // check if the 1st pushbutton is pressed
     combCheckSum = 1000;}     // if all statements are true make the checksum 1000

 if (buttonState2 == LOW) {    // check if the 2nd pushbutton is pressed
 if (buttonState1 == HIGH) {   // check if the 1st pushbutton is released
    
 if (combCheckSum == 1000) {   // check previous checksum
     combCheckSum = 1100;      // if all statements are true make the checksum 1100
 }
 }

else {
   combCheckSum = 0;          // If 1st and 2nd push button is not the corect one restart loop
 }
 }

 if (buttonState3 == LOW) {    // check if the 3rd pushbutton is pressed
 if (buttonState2 == HIGH) {   // check if the 2nd pushbutton is released
 if (combCheckSum == 1100) {   // check previous checksum
     combCheckSum = 1110;      // if all statements are true make the checksum 1110


}

else {
   combCheckSum = 0;          // If 3rd push button is not the corect one restart loop
}
}

if (buttonState4 == LOW) {    // check if the 4th pushbutton is pressed
if (buttonState3 == HIGH) {   // check if the 3rd pushbutton is released
if (combCheckSum == 1110) {   // check previous checksum
    combCheckSum = 1111;      // if all statements are true make the checksum 1111
}
}
else {
   combCheckSum = 0;          // If 4th push button is not the corect one restart loop
}
}

 //unlock the door.

 if (combCheckSum == 1111) {
   digitalWrite(RelayPin, HIGH);
   delay(3000);
   digitalWrite(RelayPin, LOW);
   combCheckSum = 0;
 }
}

*************************************************************
 EXAMPLE 2


/*
Basic Combo Lock password 2413

N1IR - Chris Johnson
email: n1ir@arrl.net

Arduino 1.0 IDE using ATTINY85
http://hlt.media.mit.edu/?p=1695

Pin 1 = RESET  Pin 8 = VCC
Pin 2 = PB3    Pin 7 = PB2
Pin 3 = PB4    Pin 6 = PB1
Pin 4 = Gnd    Pin 5 = PB0

Work Cited
http://www.electronics123.com/s.nl/it.I/id.30/.f

*/

// set pin numbers:
const int buttonPin1 = 0; // Pin 5 = PB0
const int buttonPin2 = 1; // Pin 6 = PB1
const int buttonPin3 = 2; // Pin 7 = PB2
const int buttonPin4 = 3; // Pin 2 = PB3
const int RelayPin =  4;  // Pin 3 = PB4

// variables will change:
int buttonState1 = 0;         // variable for reading the pushbutton status
int buttonState2 = 0;
int buttonState3 = 0;
int buttonState4 = 0;
int combCheckSum = 0;

void setup() {
 
  pinMode(RelayPin, OUTPUT);  // initialize the LED pin as an output:   
  pinMode(buttonPin1, INPUT); // initialize the pushbutton pin as an input:
  pinMode(buttonPin2, INPUT);
  pinMode(buttonPin3, INPUT);
  pinMode(buttonPin4, INPUT);
  // initialize the pushbutton pin as an input:
}

void loop(){
  // read the state of the pushbutton value:
  buttonState1 = digitalRead(buttonPin1);
  buttonState2 = digitalRead(buttonPin2);
  buttonState3 = digitalRead(buttonPin3);
  buttonState4 = digitalRead(buttonPin4);

 if (buttonState2 == LOW) {    // check if the 1st pushbutton is pressed
     combCheckSum = 1000;}     // if all statements are true make the checksum 1000

 if (buttonState4 == LOW) {    // check if the 2nd pushbutton is pressed
 if (buttonState2 == HIGH) {   // check if the 1st pushbutton is released
    
 if (combCheckSum == 1000) {   // check previous checksum
     combCheckSum = 1100;      // if all statements are true make the checksum 1100
 }
 }

else {
   combCheckSum = 0;          // If 1st and 2nd push button is not the corect one restart loop
 }
 }

 if (buttonState1 == LOW) {    // check if the 3rd pushbutton is pressed
 if (buttonState4 == HIGH) {   // check if the 2nd pushbutton is released
 if (combCheckSum == 1100) {   // check previous checksum
     combCheckSum = 1110;      // if all statements are true make the checksum 1110


}

else {
   combCheckSum = 0;          // If 3rd push button is not the corect one restart loop
}
}

if (buttonState3 == LOW) {    // check if the 4th pushbutton is pressed
if (buttonState1 == HIGH) {   // check if the 3rd pushbutton is released
if (combCheckSum == 1110) {   // check previous checksum
    combCheckSum = 1111;      // if all statements are true make the checksum 1111
}
}
else {
   combCheckSum = 0;          // If 4th push button is not the corect one restart loop
}
}

 //unlock the door.

 if (combCheckSum == 1111) {
   digitalWrite(RelayPin, HIGH);
   delay(3000);
   digitalWrite(RelayPin, LOW);
   combCheckSum = 0;
 }
}

Friday, July 12, 2013

Chitty Chitty Bit Bang - Bit Banging ATTiny 85 using Ubuntu and RS232

Bit Banging ATTiny 85 using Ubuntu and RS232

*****update this will work with the USB to RS232 converter*****
 just subututue ttyS0 with ttyUSB0

$ sudo avrdude -p t85 -c dasa -P /dev/ttyUSB0


Video Notes:

Read ATTINY 85, make sure connections are okay:

$ sudo avrdude -p t85 -c dasa -P /dev/ttyS0


ATtiny support in Arduino software ATTINY MASTER.zip


Modified DASA Programmer

 Make sure your RS-232 outputs 5V if using this programmer!!






Sunday, July 7, 2013

Police Style Strobe Light ATTiny85

Here is a new project for the freshmen it's a police style strobe light, you know the ones the flash three times then flash the other side three time and back and forth. I used the Arduino IDE to program and compile, I also used High-Low Tech Hardware file add-on and finally a stripped version (just resistors, took out the zeners) of the serial programmer DASA and the add-on for DASA to the Arduino software.





here is the code:

/*

Police Style Strobe Light

N1IR - Chris Johnson
email: n1ir@arrl.net

Arduino 1.0 IDE using ATTINY85
http://hlt.media.mit.edu/?p=1695

Pin 1 = RESET  Pin 8 = VCC
Pin 2 = PB3    Pin 7 = PB2
Pin 3 = PB4    Pin 6 = PB1
Pin 4 = Gnd    Pin 5 = PB0

*/

int led1 = 2; //delcare PB3 as led1
int led2 = 3; //declare PB4 as led2
int del = 500; //delay time in mS


void setup() {               
  pinMode(led1, OUTPUT); //Set led1 "PB3" to output   
  pinMode(led2, OUTPUT); //Set led2 "PB4" to output
}

// the loop routine runs over and over again forever:
 void loop() {

//Flash led1 three times 
 digitalWrite(led1, HIGH);  //Turn on led1 
 delay(del);                //Delay x amount of time
 digitalWrite(led1, LOW);   //Turn off led1
 delay(del);
 
 digitalWrite(led1, HIGH); 
 delay(del);
 digitalWrite(led1, LOW); 
 delay(del);

 digitalWrite(led1, HIGH);  dasa
 delay(del);
 digitalWrite(led1, LOW); 
 delay(del);
// End flash led1 three times

 delay(del); // Pause betwwen led1 and led2

 //Flash led2 three times
 digitalWrite(led2, HIGH); 
 delay(del);
 digitalWrite(led2, LOW); 
 delay(del);

 digitalWrite(led2, HIGH); 
 delay(del);
 digitalWrite(led2, LOW); 
 delay(del);

 digitalWrite(led2, HIGH); 
 delay(del);
 digitalWrite(led2, LOW); 
 delay(del);
// End flash led2 three times
}

Programming an ATtiny w/ Arduino 1.0 from High-Low Tech Group at MIT

This tutorial shows you how to program an ATtiny45, ATtiny85, ATtiny44 or ATtiny84 microcontroller using the Arduino software. These are small, cheap ($2-3) microcontrollers that are convenient for running simple programs. The ATtiny45 and ATtiny85 have eight legs and are almost identical, except that the ATtiny85 has twice the memory of the ATtiny45 and can therefore hold more complex programs. The ATtiny44 and ATtiny84 have 14-legs and more inputs and outputs. Thanks to Mark Sproul for his work on making the Arduino core portable across processors.

ATtiny45/85 vs. an Arduino Board

The ATtiny45 or 85 is a great option for running simple Arduino programs: it’s small, cheap and relatively easy to use. It does, however, have some limitations relative to the ATmega328P on an Arduino Uno. There are fewer pins, meaning you can’t connect as many components. There’s less flash memory (4KB or 8KB instead of 32KB), meaning your programs can’t be as big. There’s less RAM (256 or 512 bytes instead of 2KB), meaning you can’t store as much data. And there’s no hardware serial port or I2C port (Wire library), making communication trickier. (There are workarounds, like the SoftwareSerial library or the TinyWire library, but they’re not as robust and flexible.)
In short, then, if your project requires only a few simple inputs and/or outputs, you’re probably fine using an ATtiny. If you’re trying to hook up more components or do more complex communication or data processing, though, you’re probably better off with something like the ATmega328P on an Arduino Uno. If you want something smaller and cheaper than a full Arduino board, you might try using an ATmega328P on a breadboard instead.

Materials and Tools

For this tutorial, you’ll need:
  • An in-system programmer (ISP), a piece of hardware used to load programs onto the ATtiny. Options include:
  • ATtiny45 or ATtiny85 (8-pin DIP package) or an ATtiny44 or ATtiny84.
  • a solderless breadboard and jumper wires (unless you’re using the TinyProgrammer w/ the ATtiny45 or 85)
For more information, see our list of materials and parts and our list of prototyping supplies.

Download

Installing ATtiny support in Arduino

  • If you haven’t already, download the Arduino software, version 1.0.4 (1.0.3 and 1.0.1 should work too, but not 1.0.2). Install the Arduino software, following the instructions for Windows or for Mac OS X.
  • Download the ATiny master.zip file from the link above.
  • Unzip the attiny master.zip file. It should contain an “attiny-master” folder that contains an “attiny” folder.
  • Locate your Arduino sketchbook folder (you can find its location in the preferences dialog in the Arduino software)
  • Create a new sub-folder called “hardware” in the sketchbook folder, if it doesn’t exist already.
  • Copy the “attiny” folder (not the attiny-master folder) from the unzipped ATtiny master.zip to the “hardware” folder. You should end up with folder structure like Documents > Arduino > hardware > attiny that contains the file boards.txt and another folder called variants.
  • Restart the Arduino development environment.
  • You should see ATtiny entries in the Tools > Board menu.

Connecting the ATtiny

You’ll need to provide power to the ATtiny and connect it to your programmer. That is, connecting MISO, MOSI, SCK, RESET, VCC, and GND of the programmer to the corresponding pins on the ATtiny. (Or, if you’re using an circuit w/ an ATtiny, simply connect the programmer to the ISP header on the board – you may also need to power the board separately.)
Instructions and diagrams are available for:

Programming the ATtiny

Next, we can use the Arduino as an ISP to upload a program to the ATtiny:
  • Open the Blink sketch from the examples menu.
  • Change the pin numbers from 13 to 0.
  • Select the appropriate item from the Tools > Board menu (leave the serial port set to that of your Arduino board).
  • Select the appropriate item from the Tools > Programmer menu (e.g. “Arduino as ISP” if you’re using an Arduino board as the programmer, USBtinyISP for the USBtinyISP, FabISP, or TinyProgrammer, etc).
  • Upload the sketch.
You should see “Done uploading.” in the Arduino software and no error messages. If you then connect an LED between pin 0 and ground, you should see it blink on and off. Note that you may need to disconnect the LED before uploading a new program.

Configuring the ATtiny to run at 8 MHz (for SoftwareSerial support)

By default, the ATtiny’s run at 1 MHz (the setting used by the unmodified “ATtiny45″, etc. board menu items). You need to do an extra step to configure the microcontroller to run at 8 MHz – necessary for use of the SoftwareSerial library. Once you have the microcontroller connected, select the appropriate item from the Boards menu (e.g. “ATtiny45 (8 MHz)”). Then, run the “Burn Bootloader” command from the Tools menu. This configures the fuse bits of the microcontroller so it runs at 8 MHz. Note that the fuse bits keep their value until you explicitly change them, so you’ll only need to do this step once for each microcontroller. (Note this doesn’t actually burn a bootloader onto the board; you’ll still need to upload new programs using an external programmer.)

ATtiny Microcontroller Pin-Outs



Reference

The following Arduino commands should be supported:

Suggestions and Bug Reports

To report problems or suggest changes to the ATtiny support, please use the issues list on GitHub.

References

Alternative: ATmega328P on a Breadboard

If the ATtiny isn’t quite powerful enough but you still want to use a bare microcontroller instead of a full Arduino board, see this tutorial on using an ATmega328P on a breadboard. It allows you to use all the same functions and libraries as the Arduino Uno, but with just a microcontroller and a few small components.

Tuesday, June 25, 2013

YALSFT (Yet Another Laptop Saved From Trash)

Got this one working again, saved it from trash bin. Plastic around the DC jack snapped, it pushed the jack inside so it could not be plugged for a charge. Simple fix with some epoxy.





Simple DIce Project


Here is a very easy electronic dice project, we have done this before with discreet 74xx logic with a LM555, counter, adder and BCD to seven segment decoder, but this is far easier using the venerable ATTINY85V.

I programmed the ATTINY85V unconventionally using the Arduino 1.0 software, you can find instructions on how to do this at High-Low Tech Site. I did run into problems using the Arduino Uno as the programmer so I used my USBtinyISP from adafruit, I also made a zif adaptor socket some time ago (not pictured) to work with the USBtinyISP.

531946274_dcd8763cda_o.jpg

Sorry for the labelling of the schematic and PCB I only had an hour to design, test and build it on the breadboard and mill the PCB, so I did this one very hastily, next version should be cleaner. But that is pretty amazing from nothing to working prototype on a PCB and breadboard in under an hour, 10 years ago using standard etching I would've taken 4 to 6 hours to do the same.




 


here is the code
***********************************************************************************
int pinLeds1 = 3;
int pinLeds2 = 2;
int pinLeds3 = 1;
int pinLed4 = 0;
int buttonPin = 4;
int buttonState;
long ran;
int time = 2000;

void setup ()
{
  randomSeed(analogRead(0));
  pinMode (pinLeds1, OUTPUT);
  pinMode (pinLeds2, OUTPUT);
  pinMode (pinLeds3, OUTPUT);
  pinMode (pinLed4, OUTPUT);
  pinMode (buttonPin, INPUT);
  }

void loop()
{
  buttonState = digitalRead(buttonPin);
  if (buttonState == HIGH){
    ran = random(1, 7);
    if (ran == 1){
      digitalWrite (pinLed4, HIGH);
      delay (time);
    }
    if (ran == 2){
      digitalWrite (pinLeds1, HIGH);
      delay (time);
    }
    if (ran == 3){
      digitalWrite (pinLeds3, HIGH);
      digitalWrite (pinLed4, HIGH);
      delay (time);
    }
    if (ran == 4){
      digitalWrite (pinLeds1, HIGH);
      digitalWrite (pinLeds3, HIGH);
      delay (time);
    }
    if (ran == 5){
      digitalWrite (pinLeds1, HIGH);
      digitalWrite (pinLeds3, HIGH);
      digitalWrite (pinLed4, HIGH);
      delay (time);
   }
   if (ran == 6){
      digitalWrite (pinLeds1, HIGH);
      digitalWrite (pinLeds2, HIGH);
      digitalWrite (pinLeds3, HIGH);
      delay (time);
   }
  }
  digitalWrite (pinLeds1, LOW);
  digitalWrite (pinLeds2, LOW);
  digitalWrite (pinLeds3, LOW);
  digitalWrite (pinLed4, LOW);
}
***********************************************************************************

Friday, June 7, 2013

Prototype line following robot

Here is a prototype line following robot we are working on for our new engineering curriculum. It uses an arduino but the final production will be a straight AtMEGA328 on a custom board to keep cost down, programming done via SPI. Just a xtal couple of caps and a v-reg a stripped version of the arduino. I am using the QRD1114 Reflective Object Sensor, initial test indicated work best about .05" above floor sensing electrical tape against a white background, speed is about 10 feet in 3.2 seconds at 9 volts. Got one channel and one PWM working to test viability, works great got it running full steam when over a black surface and stopping when hitting a white surface. Next step I will get three channels working with two PWM to steer.



Problems ran into so far:
Used wrong FETs to drive motor, was using N-CH should have been P-CH DOE! Changed wiring to break ground instead of plus rail, used IRFZ44. stupid oversight should have caught that.








New 20x4 LCD

Just got in some new 20x4 LCD's. Nope these are not direct from china, unfortunately I can't find any good deals unless they are 16x2....very strange they use the same driver IC's I would think you could get the 20x4 about the same price maybe a couple of buck more. They are NHD-0420H1Z-FL-GBW-33V3 street price $15.50, about 10 bucks too much if you ask me.