Hi folks,

it's been a while since i posted my last instructable.
Well there are many things going around in my head right now but i managed to document my "first steps" with the ATTiny-Series of chips in this short instructable for you.

I ordered some ATTINY85 samples just because I wanted to test them :-) (everyone loves testing things, right?).
After that i started drawing some ideas into my notebook. To be honest the first thing i did was blinking a LED that´s as always a good start to check if your setup/toolchain is working. I also tried a temperature and humidity logger with DHT22 and SoftwareSerial. That was a tricky one because the DHT Librarys are mainly for 16Mhz clock (if you plan to do something like that, check how to prescale the internalclock). But i decided to show you something that is, well, just funnier.
BTW: I uploaded one of my drawings for you, its not a Rembrandt but it will show you how i got this (really) stupid idea onto a piece of paper :-P.

I only used things i had lying around to keep this project as cheap as possible (for me).
The result of this little adventure is a nice little "lightfollower robot" for around 10-15$ (3$ for me :-P)

So if you are interested in ATTINY yourself just read further.

BTW: sorry for my bad english (I´m not a native speaker)

Step 1: Getting Started With ATTiny & Tools & Materials

What you will need to get started:

- an ATTiny85 chip

- an Arduino UNO or similar

- abreadboard with some jumper-wire or an ATTINY programmer or make a programmer-shield for Arduino yourself (check the attached pictures, there is a schematic from avdweb.nl). I also made this one and I´m really happy with it the only modification i made was that i added a socket for the ATTinyx4 Series (refer to the picture and the pinout-diagrams).

- the Arduino IDE (get it here)

- the hardwarefiles for the ArduinoIDE (download and install them)

Info-Link to the playground
direct Link to the github files i used

- load the Arduino as ISP sketch on to the UNO (this will be your programmer)

- follow this instruction (http://highlowtech.org/) or this instructable (by ardutronix) and try the "blink" sketch (modifiy the PIN Nr. use the ATTINY picture as a reference! you will need the preflashed ATTINY a LED and a ~ 220Ohm Resistor for that)

Make a small breadboard-setup to check everything.
If you have done everything right the LED will blink and you´re ready to go


- Soldering Iron
- some solder
- a small wirecutter
- a dremel or other rotary-tool (just for cutting the PCB!)
- some hotglue
- tweezers
- wires


- prototyping PCB (~4cmx6cm will do it)
- 2x LDR
- 5x 10k Resistor (2x for the LDRs and 2x for the transistors BE, 1x LED)
- 1x 330Ohm Resistor (1x NEOPIXELS)
- 2x LDR
- 1x LED (colour of your choice, instead of the caster-wheel)
- 3x NEOPIXEL WS2812
- 2x Transistor (BD137 or similar)
- 2x Diode (1N4001 or similar)
- 2x micromotor (e.g. from a Hubsan micro-quadcopter)
- 1x ATTINY85 + optional (recommended) 8PIN IC Socket
- 1x 1s LIPO (I used a 140Ah from an old RC-helicopter)
- some pinheaders/sockets
- shrinktube (LDR housing)

Let´s proceed by building the hardware...

Step 2: Hardware

If you have a look at the schematics i attached, the hardware setup is pretty simple.
So if you are able to read schematics and to use a soldering iron, that´s half the trick.
Also have a look at the fotos, i added some notes for you.

I don´t provide a plan for cutting the PCB, you have the freedom to make your own design (be creative and show us your Tiny Bots).
The placement of all the electronic componets is also up to you.

Some hints from my side:

Try to allign the motors precisely (watch the angle!) we only use the motorshaft instead of wheels. (this will consume less energy)
I recommend to place the motors under the battery (weight) and to use the LDRs on the front (45° angled) paired with on LED (i´m trying to use this combination for obstacel avoidance, further tests are needed).

Further i recommend to make a little on/off jumper so the battery won´t get lost that easy.

If there is anything unclear or if you have questions, just ask me.
It won´t make much senes do make a thesis out of this little project.

Step 3: Software

1st of all download and install ADAFRUIT Neopixel Library

Here is my code with some major descriptions (i also added the sketch file). I didn´t comment every step because i think it isn´t necessary.

Upload the sketch onto your ATTiny85 and have fun with your new toy

Ideas for "personality" function + maybe code-examples are very welcome :-)

If there are any questions, feel free to ask.

I hope you enjoyed my short instructable and the little trip into the world of ATTINYs.

/* ATTINY85-Rat
a simple ATTINY85 powered lightfollowing robot. Version 2.0, by Auer Markus */

#include <avr/power.h>

#include <Adafruit_NeoPixel.h>

//motors #define LMOTOR 0 #define RMOTOR 1 //LEDs #define PIXELPIN 2 #define NUMPIXEL 3 //LDRs #define LLDR A2 #define RLDR A3

int emo = 0; float calib; boolean emostate; long oldmillis; //define Neopixels
Adafruit_NeoPixel PIXEL = Adafruit_NeoPixel(NUMPIXEL, PIXELPIN, NEO_GRB + NEO_KHZ800);

void setup() { //upscale clock else you will encounter some timingproblems (the neopixel lib is written for 16MHz) #if defined (__AVR_ATtiny85__) if (F_CPU == 16000000) clock_prescale_set(clock_div_1); #endif

//PINMODE pinMode(LMOTOR, OUTPUT); pinMode(RMOTOR, OUTPUT); pinMode(LLDR, INPUT); pinMode(LLDR, INPUT); //initialize pixels PIXEL.begin(); PIXEL.show(); delay(500); //startsequence for(int i=0;i

void loop() { if(lightfollow() == 1) { left(); } else if(lightfollow() == 2) { right(); } else if(lightfollow() == 0) { forward(); } emotion(); }

int lightfollow() { int treshold = 14; int result = 0; float left = 0; float right = 0; int samples = 1; //read LDRs for (int j = 0; j<samples; j++){

left = left + analogRead(LLDR);
right = right + (analogRead(RLDR)*calib);


//calculate the result (which direction is the light coming from?)

if((left/samples) > ((right/samples)+treshold)) {result = 2;}

else if((left/samples) < ((right/samples)-treshold)) {result = 1;}

else {result = 0;} return result; } void forward() { //Forward analogWrite(LMOTOR, 230); analogWrite(RMOTOR, 230); PIXEL.setPixelColor(0, PIXEL.Color(0,0,255)); PIXEL.setPixelColor(2, PIXEL.Color(0,0,255)); PIXEL.show(); }

void left() { //LEFT analogWrite(LMOTOR, 150); analogWrite(RMOTOR, 255); PIXEL.setPixelColor(0, PIXEL.Color(0,0,255)); //PIXEL.setPixelColor(1, PIXEL.Color(75,0,0)); PIXEL.setPixelColor(2, PIXEL.Color(0,100,0)); PIXEL.show(); }

void right() { //RIGHT analogWrite(LMOTOR, 255); analogWrite(RMOTOR, 150); PIXEL.setPixelColor(0, PIXEL.Color(0,100,0)); PIXEL.setPixelColor(2, PIXEL.Color(0,0,255)); PIXEL.show(); }

//this is for further experiments, trying to give this one a little personality :-) i´m testing what could be able to do, but no good ideas yet. void emotion() { int emotimer = 2500; int duration = random(250,750); if (millis() - oldmillis > emotimer) { oldmillis = millis(); emo = random(1,4); } if (millis() - oldmillis > duration) { emostate = !emostate; } if (emostate == true) { switch (emo) { case 1: PIXEL.setPixelColor(1, PIXEL.Color((255),(255),(255))); PIXEL.show(); break; case 2: PIXEL.setPixelColor(1, PIXEL.Color((255),(0),(0))); PIXEL.show(); break; case 3: PIXEL.setPixelColor(1, PIXEL.Color((0),(255),(0))); PIXEL.show(); break; default: PIXEL.setPixelColor(1, PIXEL.Color(random(0,255),random(0,255),random(0,255))); PIXEL.show(); break; } } else { PIXEL.setPixelColor(1, PIXEL.Color(25,0,0)); PIXEL.show(); } }

About This Instructable




Bio: I have started arduino programming in March 2014. You/Instructables will be a part of my &quot;learning-process&quot;.
More by SerialQ:ATTiny-RAT, ATTINY powered mini lightfollower TheSUN, Arduino powered design wall clock ArduinoBlueTooth(NotSoSmart)Watch 
Add instructable to: