Wednesday, 31 December 2014
Plastic Photovoltaic Cell
I have had to wait a while to play with the cell, but now that I have, I am super impressed.
The cell came from http://www.plasticphotovoltaics.org. Their website says that the Department of Energy Conversion and Storage at the Technical University of Denmark is behind this little gem.
I have tested the cell both indoors (0.67V) and outside in full sunlight (7.56V) and I must say that I am very impressed with the freeOPV. By the way, mine is version 2014 – V2.0 – A1 25.3. The website indicates that I should be able to get around 8V from the 16 strips. I’m getting close to that, so … woot!
Okay, so … what am I going to do with my freeOPV? Well, obviously it has to be something that is in keeping with the renewable energy/green principles of an organic solar cell.
I have a small vegetable patch that is about 3m x 3m sitting next to a 8m x 3m shed. The guttering on the shed feeds in to a 10,000 ltr water tank.. What I would like to do is to make the water usage of the vegetable patch as efficient as I can.
The plan is to make a watering system that responds to the moisture level detected in the soil, turning the water on for a pre-set amount of time when the moisture level falls below a set value.
I will need to embed a hygrometer in the garden that will periodically take a moisture level reading. The Arduino will read the moisture level and compare it to a stored moisture level value. If the moisture level is below the stored value, the pump is turned on for a set amount of time (say 5 minutes). If the moisture level is equal to or above the stored value, the pump remains turned off.
I’ve calculated that the roof of the shed is approximately 24m2. I’ve also calculated the average rainfall (mm) in my area and factored in a water collection efficiency value (0.9).
Area x Average Annual Rainfall x collection co-efficient = Litres Collected Per Annum.
For my system, this means an average annual rainfall of something over 14,000 litres per annum. This gives me a daily water consumption rate of around 38 litres.
Now for some more calculations. Some horticulturalists give an average of 1 inch of water per week or 630 gallons per 1,000 square feet). Damn … conversion time. That’s equivalent to 2384.80942 litres per 304 square meters … roughly 8 litres per square meter, per week.
My garden is 9 square meters, so that would mean that I need to use 70.5 litres per week … or 10.08 litres per day. Right … so I have almost 4 times as much water as my vegetable patch will use.
There are other factors to consider, different vegetable crops require different water levels at different times in their development … plus! If I use water efficient planting (using mulch and increasing the humus in the soil, I need even less water input.
Well, for the sake of this experiment, let’s keep things simple.
If the water level drops down below 10% moisture content, turn the pump on for 5 minutes.
I’m expecting that the pump will not come on all that often and it shouldn’t come on at all on rainy days..
Of course, I will want to be able to log in to the vegetable patch, night or day, from ANYWHERE on the globe and get mission critical information pumped straight to my smart-phone. I want to be interrupted while having a highly charged and pressure lunch with senior business partners with information on the drinking habits of my legumes. Clearly, I will need to embed some Wi-Fi capability into my circuit so that I can interrupt Mr CEO while I water my dinner (more likely I will get a beep while in a job interview).
An Arduino Hygrometer module comes in at around $2.00 on eBay. I’m not sure about the pump control yet, so I can’t comment on cost, but lets say about $20
Monday, 17 November 2014
ATTiny85 – Tutorial 11 – Light Input Controlling Sound Output
This is the final Freetronics 11 – Experimenters Kit tutorial. The other 10 tutorials have been covered and, I’m please to say, I have now completed all 11 tutorials with the ATTiny85.
This tutorial makes use of the Freetronics Light module (a light detecting resistor or LDR) with the Freetronics Sound module (a piezo electric module). The light level is read by the analog LDR and the light level value is passed as a tone to the piezo.
Once again, we are using a web sourced tone function that makes use of the ATTiny85 timers to produce an output tone value. This time, however, we are not using predefined wave cycle values, but using analog light level values to drive the tone.
The Piezo is connected on pin 1 (ATTiny85 pin 6), while the LDR is connected on A2 (ATTiny85 pin 3).
The LDR also connects VCC to the positive rail and GND to the negative rail.
The modified sketch:
/* Tutorial 11: Light Input Controlling Sound Output */
int piezo = 1;
int lightLevel = 0;
int duration = 300;
void setup()
{
pinMode(piezo, OUTPUT);
}
void loop()
{
lightLevel = analogRead(A2);
TinyTone(lightLevel, 4, duration);
}
void TinyTone(unsigned char divisor, unsigned char octave, unsigned long duration)
{
TCCR1 = 0x90 | (8-octave); // for 1MHz clock
OCR1C = divisor-1; // set the OCR
delay(duration);
TCCR1 = 0x90; // stop the counter
}
I believe that TCCR1 and OCR1C both point to pin 1 (but I’d have to research that a little to make sure). Reason tells me that this is so … reason and I are not always particularly good friends.
It would be nice to reduce the delay so that the tones are more smooth, it would be kinda like a light driven theramin.
Check out the rest of the tutorials here.
Friday, 14 November 2014
AVRDUDE – Pagel and BS2 error
Apparently, you need to correct the configuration problems and then everything will be fine. It is.
- Go to your Arduino IDE installation folder (something like C:\Program Files (x86)\arduino-1.0.4\hardware\tools\avr\etc.
- Before you do anything … make a backup of the file avrdude.conf
- Open the avrdude.conf file in a text editor
- locate the ATTiny85 section in the file
- locate the chip_erase_delay = 4500; line
- add the following two lines below this:
- pagel = 0xB3;
bs2 = 0xB4; - locate the memory=”lock” keyword in the ATTiny85 section
- replace this section with the following (copy and paste)
size = 1;
write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x",
"x x x x x x x x 1 1 i i i i i i";
read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0",
"0 0 0 0 0 0 0 0 o o o o o o o o";
min_write_delay = 9000;
max_write_delay = 9000;
;
Do the same for the ATTiny84 section.
You will need to restart the IDE for this to be affected.
After this, you need to
- Connect the ATTiny85 to the Arduino using your favourite ICSP
- load the sketch into the IDE
- Select the ATTiny85 board in the IDE
- Select Arduino as ISP in the IDE
- Upload your sketch to the ATTiny85.
I have now tested the abovementioned fix and the error message has now gone away. To test this, I loaded the sketch from Tutorial 10, compiled and then uploaded it to the ATTiny85 with the following, successful, result.
As you can see, the Pagel and BS2 error messages have gone … YAY! Thank you Wiki Page!
After uploading the sketch to the ATTiny85, I dropped the ATTiny85 chip into the circuit and powered it up, again, success. The circuit does what it’s supposed to do.
All in all, happy camper time.
Thursday, 13 November 2014
ATTiny85 – Tutorial 10 – Detecting Knocks and Vibration
This tutorial in it’s original form sends the detection of knocks and vibrations from the Freetronics ”Sound” module to the serial monitor. As we don’t have access to a serial monitor from the ATTiny85, instead we are going straight to the extended tutorial, monitoring our knocks and vibrations with an LED.
For this tutorial, the Piezo (Sound module) is connected on A1 (ATTiny85 pin 7) and an LED is connected to 0 (ATTiny85 pin 5).
The Piezo is read using the analogRead Arduino function and, when the analog value read from the Piezo is > 5, it will light up our LED (with a pull down resistor).
/* Project 10: Detecting Vibrations and Knocks */
int knock = 0;
void setup()
{
pinMode(0, OUTPUT);
}
void loop()
{
knock = analogRead(A1);
if(knock>5)
{
digitalWrite(0, HIGH);
delay(300);
digitalWrite(0, LOW);
}
}
The sketch is pretty straight forward … the variable knock is assigned the value of analogRead and, if it’s value is > 5 the ATTiny85 turns the LED on with digitalWrite, then waits 300 milliseconds, and then turns the LED off again with digitalWrite.
You can see from the above image that the wiring is pretty straight forward. Top right of the breadboard is the 5V regulator. The ATTiny85 was programmed using the ATTiny85 ICSP.
This is the 10th Freetronics Experimenters Kit tutorial that I’ve converted to the ATTiny85.
Check out the rest of the tutorials here.
Thursday, 6 November 2014
ATTiny85 – Tutorial 9 – Making Sounds
While this looked like a fairly simple tutorial on the face of it, it was actually a bit more difficult.
The main problem that I encountered was that the tone() function is not supported by the ATTiny85 core, so I had to do a bit of hunting around to find an equivalent method for the ATTiny85. As I expected, others had come across this same problem and had already developed a solution for it.
Two of the solutions that I tried (arduino-tiny library and a beep function) were both unsuccessful. Both produced cricket sounds (probably because the timing was wrong). However, I found Simple Tones for ATtiny that produces a nice scale and didn’t cause me too many other problems.
The connection from the ATTiny85 to the Piezo is very simple. Connect Pin 1 of the ATTiny85 to either pin of the piezo (it isn’t polarised). Connect GND to the other pin of the piezo.
Here is the sketch from the Technoblogy article referred to above (Simple Tones for ATTiny).
/* TinyTone for ATtiny85 */
// Notes
const int Note_C = 239;
const int Note_CS = 225;
const int Note_D = 213;
const int Note_DS = 201;
const int Note_E = 190;
const int Note_F = 179;
const int Note_FS = 169;
const int Note_G = 159;
const int Note_GS = 150;
const int Note_A = 142;
const int Note_AS = 134;
const int Note_B = 127;
int Speaker = 1;
void setup()
{
pinMode(Speaker, OUTPUT);
}
void loop()
{
playTune();
delay(300);
}
void TinyTone(unsigned char divisor, unsigned char octave, unsigned long duration)
{
TCCR1 = 0x90 | (8-octave); // for 1MHz clock
// TCCR1 = 0x90 | (11-octave); // for 8MHz clock
OCR1C = divisor-1; // set the OCR
delay(duration);
TCCR1 = 0x90; // stop the counter
}
// Play a scale
void playTune(void)
{
TinyTone(Note_C, 4, 500);
TinyTone(Note_D, 4, 500);
TinyTone(Note_E, 4, 500);
TinyTone(Note_F, 4, 500);
TinyTone(Note_G, 4, 500);
TinyTone(Note_A, 4, 500);
TinyTone(Note_B, 4, 500);
TinyTone(Note_C, 5, 500);
}
This sketch works just dandy, straight out of the box. Nice work Technoblogy, nice work indeed.
I need to do some more research to find out how I can get the tone() function from the arduino-tiny library to work satisfactorily, but for now, the above sketch serves my purpose.
Well, that concludes Tutorial 9. Enjoy. Once again, 9V to 5V Regulator and ATTiny85 ICSP were used to make this tutorial circuit.
Check out the rest of the tutorials here.
Tuesday, 4 November 2014
ATTiny85 – Tutorial 6 – Making Things Move With Servos
The Freetronics Tutorial 6 replaces the LED and Resistor connection on pin 11 of the Freetronics 11 with the data connection to a simple servo.
The ATTiny85 version does the same thing … not really much sense reinventing the wheel, huh?
As we learn with Tutorial 7, there are three PWM pins on the ATTiny85 to choose from. I went with the easiest and most convenient … our old friend, pin 0.
If you use the sketch from Tutorial 5 in the Freetronics Tutorial with a servo instead of an LED, then this sketch works admirably.
// Tutorial 6: Making things move with servos
int led = 0;
int brightness = 0;
int delayTime = 10;
void setup()
{
pinMode(led, OUTPUT);
}
void loop()
{
while(brightness < 255)
{
analogWrite(led, brightness);
delay(delayTime);
brightness++;
}
while(brightness > 0)
{
analogWrite(led, brightness);
delay(delayTime);
brightness--;
}
}
Of course, I’m using the ++ and – incrementing function rather than brightness = brightness + 1; and brightness = brightness –1; because I think that it looks better, but that’s just me. Let the spirit guide you in your decision …
The green jumper connects from ATTiny85 pin 0 to the yellow connector on the servo, Red connects to Orange on the Servo from the 5V rail and the black jumper connects the brown servo connection to GND.
Here’s a short video of the action.
Check out the rest of the tutorials here.
Monday, 3 November 2014
ATTiny85 – Tutorial 7 – RGB LED
I was playing around looking at the information at hand on the ATTiny85 PWM and I thought that there were only 2 PWM capable pins on the chip … apparently, I was wrong, there are three. PB0, PB1 and PB2 are all PWM. Until I realised that, I was toying with the idea of software based PWM. There are some pretty good articles, tutorials and pages relating to software PWM, so I’ll probably get around to playing with it, some other time.
In the meantime. I had another look over the Freetronics Tutorial #7 – RGB LED and I decided that the code was a little clunky. The RGB values all jump to their random values and there is a lot of blinking … that’s OK if that’s what you want. Anyway, I had a quick play and decided to make the values rise from 0 to their random value and then back down to 0 so that they fade in and out. It’s still a little inelegant, but for the sake of a decent tutorial, I thought that this would be fairly useful.
My code is as follows
//Tutorial 7: RGB LED *** EXTENDED
int rPin = 0;
int gPin = 1;
int bPin = 2;
void setup()
{
pinMode(rPin, OUTPUT);
pinMode(gPin, OUTPUT);
pinMode(bPin, OUTPUT);
analogWrite(bPin, random(0, 255));
analogWrite(gPin, random(0, 255));
analogWrite(rPin, random(0, 255));
delay(500);
}
void loop()
{
upDown(random(0,255), random(0,255), random(0,255));
delay(500);
}
void upDown(int r, int g, int b)
{
//bring the colours up
int rVal, gVal, bVal = 0;
for(int rVal = 0; rVal < r; rVal++)
{
analogWrite(rPin, rVal);
delay(10);
}
for(int gVal = 0; gVal < g; gVal++)
{
analogWrite(gPin, gVal);
delay(10);
}
for(int bVal = 0; bVal < b; bVal++)
{
analogWrite(bPin, bVal);
delay(10);
}
// return to 0
while(rVal>0)
{
rVal--;
analogWrite(rPin, rVal);
}
while(gVal>0)
{
gVal--;
analogWrite(gPin, gVal);
}
while(bVal>0)
{
bVal--;
analogWrite(bPin, bVal);
}
}
This is still fairly close to the original, with an upDown function that fades each colour in and then all of them out again.
I used my ATTiny85 ICSP to program the ATTiny85 and the 9V to 5V power regulator to supply the solderless bread board.
As you can see, there isn’t anything outside of the Arduino core being used in the code, and the wiring is very straight forward. The layout is as per the Freetronics tutorial (more or less … I’ve added a jumper from the top to bottom rails).
Here is how it looks when it’s running. Bear in mind that the cycle uses a random RGB value and splits it up, so it *should* be different for every cycle.
Well … it’s now well past my bed-time, so I’m calling it a night.
Have fun ATTiny85ers!
Check out the rest of the tutorials here.
ATTiny85 – Tutorial 5 – Dimming LED using PWM
This tutorial is a very simple conversion from ATMEGA328P to ATTiny85, there is only one pin involved in producing output, so we only need to change from pin 11 to pin 0. On the ATTiny85, there are three hardware PWM pins … pin 0, pin 1 and pin2 , so it’s simply a matter of switching over to Pin 0 and away we go.
I’ve changed the sketch for personal taste (and I think, efficiency), you’re free to use the Freetronics version of the code if you like … it’s no great shakes on something this small.
/* project 5: Controlling LED brightness with PWM */
int led = 0;
int brightness = 0;
int delayTime = 10;
void setup()
{
pinMode(led, OUTPUT);
}
void loop()
{
while (brightness < 255)
{
analogWrite(led, brightness);
delay(delayTime);
brightness++;
}
while (brightness > 0)
{
analogWrite(led, brightness);
delay(delayTime);
brightness--;
}
}
As you will see from the following image, there isn’t much to the wiring for this project.
And here’s the circuit running through it’s light/dim wizardry.
Once again, I’m using my ATTiny85 ICSP to program the ATTiny85 using the Arduino UNO and my 9V to 5V power regulator to supply 5V to the circuit.
Check out the rest of the tutorials here.
Friday, 31 October 2014
ATTiny85 Tutorials
I thought that it may be easier for everyone if I put together a single page that lists all of the ATTiny85 tutorials on this blog so that you can come here and launch off to the tutorial that you want to see.
Once again, these are based on the Freetronics Eleven tutorials that you get when you buy the Experimenters Kit.
My goal is to produce an ATTiny85 equivalent for each of the tutorials in that guide, so that you can take advantage of both the Freetronics basic tutorials and my experimentations with the ATTiny85.
I am a hobbyist, not an expert!
Tutorials
| Freetronics Tutorial | Comments |
| 01 – Controlling an LED | |
| 02 – Controlling 8 LED | 4 LED |
| 03 – Reading Digital (On/Off) Input | 4 LED |
| 04 – Reading Analog (Variable) Input | |
| 05 – Dimming LED Using PWM | |
| 06 – Making Things Move With Servos | |
| 07 – RGB LED | |
| 08 – Drive More Outputs With A Shift Register | 8 LED using 75HC595 |
| 09 – Making Sounds | Using alternative tone() function |
| 10 – Detecting Vibrations and Knocks | |
| 11 – Light Input Controlling Sound Output |
I’m going to come back to this article and fill in the blanks as I complete the tutorials, so check in from time to time to see how we get along.
I will include the Arduino sketch along with the article so that you can see how the code differs between the chips. I am still planning on doing the same with the ATTiny84 and I’m likely to use the same format.
Typically, the tutorials will include a pin assignment section, an image or video of the completed circuit, the Arduino code and some commentary on the differences that I’ve encountered and the approach that I’ve taken.
Thursday, 30 October 2014
ATTiny85 Tutorial 4 – Reading Analog (Variable) Input
This is the 4th tutorial in the Freetronics Experimenters Kit converted to ATTiny85.
With this tutorial, the main changes from the original tutorial is again the pin assignments. But, also, the ATTiny85 is not connected to the PC via the USB cable, so Serial.begin, Serial.print and Serial.println are redundant. I have removed them from the sketch.
In this tutorial, the light sensor is connected to first Analog Digital Comparator pin (physical pin 7 ADC1). In your sketch, the analog pins are A1, A2 and A3 … so for the purpose of this tutorial, we’re using A1. The LED is connected on pin 0 … got that, A1 and 0 … right, let’s move on.
The modified sketch is as follows.
int led = 0;
int lightLevel;
void setup()
{
pinMode(led, OUTPUT);
}
void loop()
{
lightLevel = analogRead(A1);
digitalWrite(led, HIGH);
delay(lightLevel);
digitalWrite(led, LOW);
delay(lightLevel);
}
Within the loop function, the ATTiny85 reads the value of the light sensor, this gives a value of 0 – 5V. The value is read as an integer value from 0 – 1023. This value is assigned to the lightLevel variable that is used to set the blink rate of the LED. The more light there is, the slower the blink rate.
The yellow wire connects the light sensor to A1 on the ATTiny85 and the LED is connected to 0 on the ATTiny85.
To test this circuit, I powered it up and then turned on my LED lamp above the sensor … as you would expect, the blink rate slowed down, then I swung the lamp away from the sensor to give an analog light variation and the blink rate sped up as less light was hitting the sensor … all working as you would expect.
Again, I programmed the ATTiny85 using my ATTiny85 ICSP and powered the breadboard using my 5V power regulator.
That’ll do for now, I’ll come back to these tutorials next week.
Check out the rest of the tutorials here.
ATTiny85 Tutorial 8 – Drive More Outputs With A Shift Register
For this tutorial, I have tried to fit all of the components onto a half+ board. Of course, I’m using my 5V regulator, so I am cheating slightly. However, the ATTiny85 and the 74HC595 both fit on the board along with the required 8 LED.
The original Arduino sketch includes the instantiation of Serial communication, that hasn’t been enabled on my ATTiny85, so I’m just commenting it out in the sketch. I am also omitting the smoothing capacitor between data and GND, if you want to include it, by all means, knock yourself out.
The shift register tutorial uses only digital pins in the original, so I am substituting like for like in the ATTiny85 platform.
The wiring is a little confusing (probably because I crammed it all into a half+ board), but there really isn’t much to it.
So long as you get the connections between the ATTiny85 and the 74HC595, then it’s really just a matter of poke and play (of course, you’ll need to be careful with the Vcc and GND connections!).
I’ve taken the liberty of changing the sketch to something closer to what I’ll actually be using, so beware that there are some functional changes (although very few).
Onto the sketch:
/*
Shift Register Example
Turning on the outputs of a 74HC595 using an array.
Modified for ATTiny85
Hardware:
* 74HC595 shift register
* ATTiny85
* LEDs attached to each of the outputs of the shift register
*/
//Pin connected to ST_CP (12) of 74HC595
int latchPin = 2;
//Pin connected to SH_CP (11) of 74HC595
int clockPin = 3;
////Pin connected to DS (14) of 74HC595
int dataPin = 0;
//holders for information you're going to pass to shifting function
byte data;
byte chaseArray[8];
void setup() {
//set pins to output because they are addressed in the main loop
pinMode(latchPin, OUTPUT);
// Serial.begin(9600);
chaseArray[0] = 1; //00000001
chaseArray[1] = 2; //00000010
chaseArray[2] = 4; //00000100
chaseArray[3] = 8; //00001000
chaseArray[4] = 16; //00010000
chaseArray[5] = 32; //00100000
chaseArray[6] = 64; //01000000
chaseArray[7] = 128; //10000000
//function that blinks all the LEDs
//gets passed the number of blinks and the pause time
blinkAll_2Bytes(2, 500);
}
void loop() {
for (int j = 0; j < 8; j++) {
//load the light sequence you want from array
data = chaseArray[j];
//ground latchPin and hold low for as long as you are transmitting
digitalWrite(latchPin, 0);
//move 'em out
shiftOut(dataPin, clockPin, data);
//return the latch pin high to signal chip that it
//no longer needs to listen for information
digitalWrite(latchPin, 1);
delay(60);
}
}
// the heart of the program
void shiftOut(int myDataPin, int myClockPin, byte myDataOut) {
// This shifts 8 bits out MSB first,
//on the rising edge of the clock,
//clock idles low
//internal function setup
int i=0;
int pinState;
pinMode(myClockPin, OUTPUT);
pinMode(myDataPin, OUTPUT);
//clear everything out just in case to
//prepare shift register for bit shifting
digitalWrite(myDataPin, 0);
digitalWrite(myClockPin, 0);
//for each bit in the byte myDataOut
//NOTICE THAT WE ARE COUNTING DOWN in our for loop
//This means that 000001 or "1" will go through such
//that it will be pin Q0 that lights.
for (i=7; i>=0; i--) {
digitalWrite(myClockPin, 0);
//if the value passed to myDataOut and a bitmask result
// true then... so if we are at i=6 and our value is
// %11010100 it would the code compares it to %01000000
// and proceeds to set pinState to 1.
if ( myDataOut & (1<<i) ) {
pinState= 1;
}
else {
pinState= 0;
}
//Sets the pin to HIGH or LOW depending on pinState
digitalWrite(myDataPin, pinState);
//register shifts bits on upstroke of clock pin
digitalWrite(myClockPin, 1);
//zero the data pin after shift to prevent bleed through
digitalWrite(myDataPin, 0);
}
//stop shifting
digitalWrite(myClockPin, 0);
}
//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_2Bytes(int n, int d) {
digitalWrite(latchPin, 0);
shiftOut(dataPin, clockPin, 0);
shiftOut(dataPin, clockPin, 0);
digitalWrite(latchPin, 1);
delay(200);
for (int x = 0; x < n; x++) {
digitalWrite(latchPin, 0);
shiftOut(dataPin, clockPin, 255);
shiftOut(dataPin, clockPin, 255);
digitalWrite(latchPin, 1);
delay(d);
digitalWrite(latchPin, 0);
shiftOut(dataPin, clockPin, 0);
shiftOut(dataPin, clockPin, 0);
digitalWrite(latchPin, 1);
delay(d);
}
}
I thoroughly recommend that you do this tutorial on the Arduino first before attempting the ATTiny85 version, so that you know what to expect and how the connections work. Other than that, this makes a nice and tiny board project, now I need to play with laying this out on a board so that I can etch it … that should be fun.
The above video is the ATTiny85 and 75HC595 sub board connected to breadboarded LED. This is the next step on from the breadboard version in this article, but uses the same sketch and is functionally identical.
Check out the rest of the tutorials here.
Tuesday, 14 October 2014
Prototype Embedded Electronics – Together
Now that I have completed the three circuits that I had planned to embed in the Steam Punk prop (Torch, Pulsing/Fading LED, LED Chaser) it’s time to put them together in a single main/sub configuration as they would be in the prop. I had to cheat a little here … I couldn’t find one of my male to male DuPont connectors and, rather than make a new one, I opted for the easier option of replacing the 2x2 SMD circuit with the 4 x 5 LED “Desk Light” circuit. In terms of testing the components together, this should really have no practical impact on the outcome. Sure, they are through hole components … and a lot more of them, so the only real difference from the perspective of testing the overall concept is that it will draw more power from the battery. In the embedded scenario, I need to rebuild ALL of the component circuits, so there really isn’t anything lost there.
I have connected a 9V battery to my trusty solderless breadboard and then connected each of the components to the power rails. The Torch and Pulsing/Fading circuits are connected to the 9V directly, whereas the LED Chaser is connected to 9V via a 5V Regulator (I opted for an early version of this as I didn’t need the optional LED power indicator).
The result is as expected … it all works just dandy. I should probably go ahead and work out power consumption so that I have an idea of how long the battery will last in the prop. I’m still toying with the idea of also embedding a battery charger circuit … but it is easy and cheap enough to use a commercial – “off the shelf” charger so I’m not going to bother with that … yet.
There are still more tweaks and optimisations that I am planning, but that’s for later.
I present to you the prototype embedded electronics of the Steam Punk prop …
Fiat Lux
Monday, 13 October 2014
ATTiny85 Shift Register – Sub Board Populated
This weekend I completed the preparation work on the LED Sub Board for the ATTiny85 Shift Register board.
The preparation work was simply cutting the board to shape and filing it down to make it round.
Tonight, I populated the board with the resistors (SMD 0805 120Ω), the pin headers and the 3mm blue LED. There really wasn’t much involved in this other than getting down and doing it. I could have made my live a little easier by spacing the pin headers more … but, you live and learn.
The trickiest part was soldering the SMD resistors. I did this by first clipping the resistor onto the board with a spring clip and soldering one side (the inside edge) and then going around and soldering the outside. After that, I soldered the pin headers and finally, the LED. I gave the board, LED and pins a test using the multimeter and found that the pin header for LED 2 was dry soldered, so I went over it again until I had a decent solder filet.
The top of the board looks pretty straight forward, nothing much to see.
This is still a prototype board, so I’m not terribly fussed. I’m happy with the shaping of the board, but, again, I could make my life easier by making this slightly larger. In the final version, I plan to have sockets instead of LED soldered to the board as the LED will be mounted on the inside of a Steam Punk prop … not held flat to a disc.
Well, as far as a prototype goes, I think I’m happy with the outcome. I’ve learned some useful stuff about this type of circuit and I can use what I’ve learned when I’m making the version that will mount inside the prop, such as the spacing of the pin headers and the spacing and size of the screw mounting holes.
This project will probably end up as wearable electronics, I plan to mount the sub-board in opaque resin and make a badge out of it. I’ll also decrease the delay interval in the Arduino sketch to run roughly double the speed.
Wednesday, 8 October 2014
ATTiny85 Shift Register – Main Board Populated
Tonight, I populated the main board for this project and made the necessary connecting wires. You can see the previous post at ATTiny85 Shift Register – Etched.
I started out by making the 9 DuPont Female to Female 1 Pin wires, 8 yellow and 1 black. The yellow wires connect Q1 – Q8 on the shift register to (ultimately) LED 1 – LED 8 on the sub-board. This was mostly a process that took time. I cut the wires to 100mm, stripped 5mm from both ends of the wire, tinned the wires, tinned the DuPont connectors, soldered the wire to the DuPont connectors, slipped the pin housing onto the connector … job done. Although, 9 wires with a little finessing ended up taking me about 45 minutes to complete, I’m glad that job is done.
The next task was to populate the Main Board with the 8 and 16 pin DIP and the pin headers … there aren’t any heat sensitive components here, so it was, again, just a process.
Tested the board and connections with the multimeter, all happy.
After that, dropped in the ATTiny85 and 74HC595
I still have to pull the ATTiny85 and upload the modified Shift Register sketch onto it. I plan to test the main board by connecting it to 8 LED and resistors on a solderless breadboard. But … I’m too lazy and I think that I’ve done enough tinkering today.
huh … what do you know … I’m not that lazy!
Putting the Electronics together – Planning
The main reason that I’ve been tinkering with electronics is my longer term goal of embedding some interesting lighting effects into a Steam Punk prop. That was where all of this started.
Now I have some decisions to make about which lighting effect circuits I want to include.
I want:
- A pulsing/fading light acting as a power indicator and with a cool translucent – through hole cover (i.e. the Mac power indicator);
- Chasing lights to come on when the trigger is pulled; and
- A torch-light at the front of the prop
I’ve done a couple of pulse fade circuits, all with varying degrees of success (well … appearance). My two favourites are the 9V PUT transistor pulse fade that I found in the Make! book and the ATTiny85 pulsing LED that I modified from the Arduino as ISP sketch. The PUT version is neat and quite cheap, it doesn’t require any expensive parts (relatively), the most costly part is the PUT transistor (2N6027), but, at around $0.27AUD per transistor, I can live with that, this pushes the PUT version to around $0.73 per board. The ATTiny85 version has far fewer parts, but the ATTiny85 is much more expensive than a PUT transistor so it ends up costing around $2.48AUD.
The Chasing Lights is a bit of a no brainer, I’m going to go with the ATTiny85 + LED Sub-board option. The total cost of the board and sub-board comes to $4.37AUD.
Finally, I’m going to rebuild the 2x2 SMD LED Matrix project and change the layout a little. This was a great learning circuit for a couple of reasons and at a cost of around $0.49 it’s nice a cheap too!
There are a couple of additional costs, such as switches. For the chasing lights, I’ll either use a momentary switch or a lever switch, which way I go is going to depend on the way that I design the trigger for the prop. Apart from that, there’s about $1.00 worth of wire.
So, the embedded electronics come in at (PUT) $6.59 or (ATTiny84) $8.34 … plus the switches.
The above block diagram shows the overall design using the ATTiny85 Pulse/Fade component while the one below shows the overall design using the PUT Pulse/Fade component.
With the PUT Pulse/Fade, I’ve dropped a switch and put the SMD LED onto the 9V power source, rather than the 5V regulated power source.
My next step from here is to put these circuit boards together on a prototype “board” to test the overall concept.
Tuesday, 7 October 2014
ATTiny85 Shift Register – Etched Boards
Okay, so I’ve etched the boards for the ATTiny85 + Shift Register and the LED + Resistor sub-board.
This is the main board, top left is the ATTiny85, middle is the 74HC595 and the row of 9 pins at the bottom is the interface to the sub-board.
This went fairly well, I tested all of the traces and found that the board measures up OK.
And, above is the sub-board with LED and SMD (0805) resistors coming in to two pin headers (4 pin and 5 pin) for the interface to the main board. As you can see in the picture, there is some misalignment in the transfer. This happened because I needed to overprint the board (the first run with toner transfer didn’t work very well). It also lead, more seriously, to three points on the board where the misalignment resulted in bridging. All of the bridges occurred on the SMD pads. I cut the trace with a scalpel and the scraped off the copper to make sure that the bridge was removed.
After testing the modified/corrected board with the multimeter on continuity, I found that I had eliminated all of the bridges and there were no gaps in the trace that would cause the board to fail.
Next, I’ll be drilling and filling.
Finally, here’s another 5V regulator (LM7805) circuit with a power indicator LED and resistor.
This is just the same as the last one with two modifications:
- I’ve added a second set of pin headers to improve the mechanical stability of the board when it is plugged in to a solderless breadboard; and
- LED and resistor (far left in the above image).
Well, that’s it for tonight. Good luck and happy soldering!
ATTiny85 Shift Register – With Sub Board
Breaking the design of the circuit into a controller board and LED sub-board arrangement seems to be a bit … inefficient. Of course, this could be just because of my design.
On this board there are just the ATTiny85, 74HC595 (Shift Register) and the necessary pin blocks for connecting it to the round LED sub board. There’re probably more efficient designs for this, but I’ve simply removed the LED and resistors and then re-routed the traces.
The LED sub-board is probably more like what I wanted. At the moment, the 9 pin headers are aligned for main and sub-board simply connecting using a straight forward pin block pairing. However, I’m likely to connect the main and sub-board with jumper wires rather than male pin block to female pin block, so the arrangement of the pin headers on the main board are kinda irrelevant and I could make the design more efficient on the main board, for instance, I could have the pin header right up against the 74HC595, meaning that the routing would be much less of a dogs breakfast. That would also mean that I could re-orient the ATTiny85 and have the traces from that to the 74HC595 more straight forward too.
With that in mind … the arrangement of the main board should probably be more like the following.
This is a much more straight forward design and doesn’t waste any space. The new design (above) is 40mm x 40mm, so I can save a bit of space using this layout rather than the one above. 1 wire to carry the GND and 8 for the Q0 – Q7 pins on the 74HC595 chip.
That should probably cover the design side fairly well. OK, so this is the design that I’m going to go with.
I guess the other thing that I like more about this design is that I can have a couple of LED sub-boards with different coloured and sized LED and play with the visual design of the board more.
ATTiny85 Shift Register – Plan
I’ve been struggling for a while to work out a design for an ATTiny85 circuit with a shift register and 8 LED laid out on a single sided copper clad PCB. My main issue has been with the overlapping of traces.
Well, today I think that I’ve created a design that will work.
I’m going to start making this board tonight and see if my design is right and then I’ll start tinkering with the design. I want to make a circular chasing light on a @40mm diameter board. So far, my designs for this circuit have left a lot to be desired so I’ll see how I get along.
The main questions to be answered in this design are:
- Can I re-arrange the LED and resistors around a circular PCB; and
- Is the design sufficiently optimised.
Ultimately, the chasing LED circuit will be embedded in another device, so I need the PCB to be of an optimal size. Once the board design is proven, then I can jigger around with it some more.
Honestly, I don’t mind if the circuit doesn’t live up to my expectations, it’s all learning.
Of course, the alternative is a sub-board with the LED and resistors on it.
Tuesday, 30 September 2014
Dual Sided PCB – A first foray – Part 1
Now that I am fairly confident in my ability to produce a single sided printed circuit board, it’s time to move on to the more complex issue of producing a 2 sided printed circuit board.
The plan is to make a circular PCB with a shift register and 8 LED. The circuit will be driven by an ATTiny85 that attaches via 3 jumpers to the board (so that I can free up some space on the board) and to power via another 2 jumpers.
Above is the circuit design showing both the top and bottom layer.
I started out by using a hole saw to cut the double sided copper clad board to the right shape. The main downside to this method is that you end up with a pilot hole in the middle of the board. Fortunately, the pilot hole ends up underneath the 16 pin DIP and not much routing needs to be considered.
Normally, when transfer printing a single layer PCB, the bottom layer is printed out as a mirror image so that when it is transferred to the board, it’s around the right way. For dual layer, it seems that the top layer is printed out in positive and transferred to the PCB so that it will match up with the bottom layer. I printed out both top (positive) and bottom (mirror) onto an A4 sheet of paper, held the sheets with the toner side facing each other and held it up to the light and it looked like the above image … so I think that this is the right way to go.
I also included three “register” points on the design so that I could align the two faces. I plan to cut the A4 sheet down to the design and then hold both top and bottom layer to the copper clad board using the register points for aligning them.
The other three holes in the design are for mounting screws.
The top layer includes the ATTiny85 connections (4 o’clock on the design), most of the shift register connections and the anode connections for the LED.
The bottom layer includes the resistors (I’m using 0805 SMD), the cathode connections for the LED, and the power connections (note that the bottom layer as shown above is NOT mirrored … if you are going to use this design, you will need to mirror the image first).
One of the things that I haven’t quite worked out yet is the connection of the DIP on two layers. I may have to do some rearranging of traces, bending of DIP legs so that they can be surface mounted on the top layer.
This design requires:
- 8 x 0805 SMD resistors (appropriate for your LED) I’m using 100Ω;
- 8 x LED;
- 1 x 16 pin DIP;
- 1 x 3 pin header (connects to the ATTiny85);
- 1 x 2 pin header (connects Vcc and GND);
- 1 x 74HC595 Shift Register IC;
To run the circuit, I’m going to have the ATTiny85 on a solderless bread board running my modified Shift Register sketch.
Well … that’s the plan. I’ll do the toner transfer and etch tonight and see how far I get along with the build.
Wednesday, 24 September 2014
Arduino – One Button Multiple Functions
One of the things that I want to do with my LED functions is to control them with a single momentary switch. This means that I’ll have less hardware that the user needs to interact with, but the trade-off is that the user will need to press the button multiple times to get the function that they want.
The idea is to use a momentary switch that supplies current to the three LED functions (Glow, Chase, Lamp). I plan to do this by implementing an ATTiny85 to serve as a switch controller. First, though, the proof of concept is by controlling three LED with one momentary switch.
The breadboard is fairly straight forward. The Momentary Switch is connected to Pin 12 on the UNO and has a pull-down resistor. The three LED (acting as proxies for the ATTiny85 that will control the LED functions) connect to Pins 7, 8 and 9 on the UNO. When the button is pressed, a variable is incremented and passed to a switch statement, so that you get all possible combinations of the three LED (X00, 0X0, 00X, XX0, 0XX, X0X, XXX and 000) (I think).
I’ve had a bit of a look around on the interweb and haven’t found anything startling … so I’ve used the basic Button example on the Arduino site and mixed it up with the switch control to arrive at a design that I think will work.
Most of the smarts for this happen in the sketch.
int buttonPin = 12;
int fi = 7;
int se = 8;
int th = 9;
int buttonPushCounter = 0;
int buttonState = 0;
int lastButtonState = 0;
void setup()
{
Serial.begin(9600);
pinMode(buttonPin, INPUT);
pinMode(fi, OUTPUT);
pinMode(se, OUTPUT);
pinMode(th, OUTPUT);
digitalWrite(fi, HIGH);
digitalWrite(se, HIGH);
digitalWrite(th, HIGH);
delay(300);
digitalWrite(fi, LOW);
digitalWrite(se, LOW);
digitalWrite(th, LOW);
}
void loop()
{
// read the pushbutton input pin:
buttonState = digitalRead(buttonPin);
// compare the buttonState to its previous state
if (buttonState != lastButtonState) {
// if the state has changed, increment the counter
if (buttonState == HIGH) {
// if the current state is HIGH then the button
// wend from off to on:
buttonPushCounter++;
if(buttonPushCounter == 9){ buttonPushCounter = 1;}
Serial.println("on");
Serial.print("number of button pushes: ");
Serial.println(buttonPushCounter);
}
else {
// if the current state is LOW then the button
// went from on to off:
Serial.println("off");
}
}
// save the current state as the last state,
//for next time through the loop
lastButtonState = buttonState;
switch(buttonPushCounter)
{
case 1:
digitalWrite(fi, HIGH);
digitalWrite(se, LOW);
digitalWrite(th, LOW);
break;
case 2:
digitalWrite(fi, LOW);
digitalWrite(se, HIGH);
digitalWrite(th, LOW);
break;
case 3:
digitalWrite(fi, LOW);
digitalWrite(se, LOW);
digitalWrite(th, HIGH);
break;
case 4:
digitalWrite(fi, HIGH);
digitalWrite(se, HIGH);
digitalWrite(th, LOW);
break;
case 5:
digitalWrite(fi, HIGH);
digitalWrite(se, LOW);
digitalWrite(th, HIGH);
break;
case 6:
digitalWrite(fi, LOW);
digitalWrite(se, HIGH);
digitalWrite(th, HIGH);
break;
case 7:
digitalWrite(fi, HIGH);
digitalWrite(se, HIGH);
digitalWrite(th, HIGH);
break;
case 8:
digitalWrite(fi, LOW);
digitalWrite(se, LOW);
digitalWrite(th, LOW);
break;
}
Serial.println(buttonState);
}
I think that I can probably simplify the code a bit more, but it works OK. The only real problem that I have with this code is that the button press has to be fairly confident … a little press does nothing.
I guess that you could scale the number of functions up to the number of pins that you have available, or maybe a shift register? Dunno, I haven’t tried that yet.
The next step with this design is to replace the 3 LED with 3 ATTiny85 to see if that works. The plan is to connect Vcc on the ATTiny85 to Pins 7, 8, 9 of the UNO, if it works the way I hope, then the button press will turn each of the ATTiny85 on and off according to the switch statement. We’ll see.
Paypal Donations
Donations to help me to keep up the lunacy are greatly appreciated, but NOT mandatory.

