Archive for

November, 2009

...

8 bits Shift Register – 74HC595

no comments

On the heals of the success with the Arduino kit last week, I went ahead and bought some extra parts: a 74HC595, 8 bits Shift Register, some red/green/orange LEDS (TLUV5300), and a bigger bread board. I also got some resistors, however, the proved to be wrong. The guy in the shop suggested 15 Ohm for 5 V, however, all the LED resistor calculators I looked at suggested 100-120 Ohm, I I’ll get some new ones tomorrow.

So for the application. Not very fancy so far, but great fun to see the register chip working so easily. Based on this code example by Carlyn Maw and Tom Igoe, and the tutorial at SparkFun (for their 74HC595 offering), I hacked away and came up with a "binary counter" of sorts. Here’s some pictures, and the code that went with it. I modified the example to use the shiftOut Arduino library function.

On the breadboard, yellow is +5V, and brown in ground. The extra breakaway at row 25 does nothing but support the 4 wire sound cable I used hook up to the Arduino. From left to right, Arduino to 74HC595: 12 -> SH_CP (clock), 11 -> ST_CP (latch), 9 -> DS (data). Finally, don’t be confused by the series of resistors to the right. I wanted to see the difference between 15 and 90 Ohm on one of the LEDS; it was almost not noticeable.


// Based on:
// http://arduino.cc/en/Tutorial/ShftOut13

//Pin connected to ST_CP of 74HC595
int latchPin = 11;
//Pin connected to SH_CP of 74HC595
int clockPin = 12;
////Pin connected to DS of 74HC595
int dataPin = 9;

//holders for infromation you're going to pass to shifting function
//byte data;

void setup() {
//set pins to output because they are addressed in the main loop
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);

//function that blinks all the LEDs
//gets passed the number of blinks and the pause time
blinkAll(2,500);
}

void loop() {
for (int j = 0; j < 255; j++) {
write(j);
}

}

void write(byte data) {
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, MSBFIRST, data);
digitalWrite(latchPin, HIGH);
delay(1000);
}

//blinks the whole register based on the number of times you want to
//blink "n" and the pause between them "d"
//starts with a moment of darkness to make sure the first blink
//has its full visual effect.
void blinkAll(int n, int d) {
write(0);
for (int x = 0; x < n; x++) {
write(255);
write(0);
}
}

Arduino on Ubuntu 8.04

no comments

A few days ago I set up the Arduino development kit on Fedora 11. Here the steps for Ubuntu 8.04 follow, based on this. I was using a slightly custom setup, so the Java install is assumed, and the extra repository suggested here (Problems Ubuntu 8.04 amd64) was not added. Instead I download the packages directly. Furthermore, I wound that it was better to go for a setup in my home directory, as you frequently have to tweak libraries and other files.

Finally, this includes a new library for DHCP by Jordan Terrell.


sudo apt-get install gcc-avr avr-libc binutils-avr avrdude uisp

# Add your personal user to these groups: dialout, uucp
sudo emacs /etc/group

cd ~
mkdir arduino
cd arduino

# Download stuff for manual installation.
wget http://arduino.googlecode.com/files/arduino-0017.tgz
tar zxvf arduino-0017.tgz

wget http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip
unzip rxtx-2.2pre2-bins.zip

wget http://www.thepotterproject.net/NewSoftSerial%20JL.zip
unzip "NewSoftSerial JL.zip"

wget http://www.thepotterproject.net/Picaso.zip
unzip Picaso.zip -d Picaso

wget http://blog.jordanterrell.com/public/Arduino-DHCPv0.4.zip
unzip Arduino-DHCPv0.4.zip -d dhcp

# Use the new avrdude
cd arduino-0017/hardware/tools; rm avrdude avrdude.conf; ln -s /usr/bin/avrdude; ln -s /etc/avrdude.conf; ll; cd -

# Use the new RXTX
cd arduino-0017/lib; rm librxtxSerial.so RXTXcomm.jar; ln -s ../../rxtx-2.2pre2-bins/x86_64-unknown-linux-gnu/librxtxSerial.so; ln -s ../../rxtx-2.2pre2-bins/RXTXcomm.jar; ll; cd -

# Make NewSoftSerial, Picaso, and Dhcp libraries available
cd arduino-0017/hardware/libraries; ln -s ../../../NewSoftSerial; ln -s ../../../Picaso; ln -s ../../../dhcp; ll; cd -

That was the basic setup, which should hopefully work in most cases. However, for gcc version 4.2.2 there is a special issue with the gcc-avr package. I’ll download it and update manually.


[back in 5...]

Bad Behavior has blocked 114 access attempts in the last 7 days.