Ads
Tuesday, November 18, 2008
Monday, November 17, 2008
Saturday, November 15, 2008
Adding a shift register to the mix
So I hooked up a shift register (SN74HC595N) (8 bits output) to the ATMega168 (avr).
I wrote code. It wouldn't work. I couldn't figure out why. It sometimes worked, sometimes didn't. The lower 4 bits would work, sometimes...
Turns out, I forgot to set the 'you allowed to send information/output stuff' (SRCLR (overriding clear)) pin to high (tie it to vcc), so it was floating. This made it work sometimes, and most of the time it didn't work.
Once I put +5v on pin 10 (SRCLR) everything worked out great. I cleaned up all of the crazy code that I wrote trying to get something to work (I thought it was a code problem, not a "I missed hooking up a pin"). I had LED's hooked up to the 8 outputs of the shift register. It just lights the last led, then the next up(with the first), and etc until it lights all of them.
oh, for the connecting of stuffs, I used this diagram
from http://www.windmeadow.com/node/20 (note: On that page, he mentions adding power to the shift register as its not on the diagram. I didn't read that until making this post, but just remembered to do it from the data sheet on the shift register. Sucks that I didn't remember to hookup pin 10!) I put the LEDS on QA -QH.
the code (blinkin.c):
#include <avr/io.h>
#include <util/delay.h>
#define nop() __asm__ __volatile__ ("nop")
#define F_CPU 20000000UL //My chip is 20 Mhz
//make sure F_CPU is after #include <util/delay.h>
void send_byte_to_shift_register(int8_t bite);
int main(void)
{
int j = 1;
while(1)
{
send_byte_to_shift_register(j-1);
_delay_ms(500.0);
j = j*2;
if ( j == 512)
{j = 1;}
}
return 0;
}
void send_byte_to_shift_register(int8_t bite)
//should be able to use SPI instead of this way...
{
DDRB = 0xFF;
int i = 0;
int out = 0;
for(i=0;i<8;i++)
{
out = (bite >> i) & 0x01; //extract 0 or 1
//0x01 for last bit only, and >> to get location i
if (out == 1) {PORTB = (1 << PINB3); }
else {PORTB = (1 >> PINB3); }
PORTB = (1 << PINB1); //clock;
}
PORTB = (1<<PINB2); //latch the shift register
return;
}
yeah, so my sister yells out "STELLLLA" at the end of the video. Think of it as a bonus.
Posted by
sstc
at
11/15/2008 11:45:00 PM
0
comments
Labels: alarm_clock
Friday, November 14, 2008
Tuesday, November 11, 2008
Flashing blue lights in my mirror
I got pulled over by a mis-informed cop for driving an unlicensed scooter.
Turns out I was legal.
So I tried to complain and this was their response. (I used two browsers... its on their end)
"""
Microsoft VBScript runtime error '800a01ad'
ActiveX component can't create object: 'CDONTS.NewMail'
/web5-2/communication/ofcemail.asp, line 49
"""
and still broken after the vacation.
Posted by
sstc
at
11/11/2008 04:28:00 PM
3
comments
Labels: moped
Tuesday, November 04, 2008
Election Day! (and I am missing it)
I will be happily ignorant of the outcome of the election as I am on my honeymoon.
My only regret is that I may miss the ensuing riots.
(ha!)
(no seriously, someone please secure my belongings)
I hope everyone is having a good week, catch you at the end of the week.
-written 1.5 weeks before the election/marriage
Posted by
sstc
at
11/04/2008 04:00:00 AM
0
comments
Sunday, November 02, 2008
Candy!
update: the candy was a big secret? it seems. So I am re posting this the day after.
We got candy for the upcoming big event.
I forgot to post a picture of the non-chocolate candy. So here it is.
nom nom nom.
Posted by
sstc
at
11/02/2008 12:54:00 PM
0
comments



















