3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.

Flashlight tag

Step 3Uploading the software

Uploading the software
To upload the program to the ATtiny, we need to use the Arduino. The Arduino needs to run the special software from MIT. (http://hlt.media.mit.edu/?p=1229)

Installing the ATtiny support:
  • Download: attiny45_85.zip
  • 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.
  • Copy the attiny45_85 folder from the attiny45_85.zip to the hardware folder.
  • Restart the Arduino development environment.
To turn the Arduino in a programmer we need to run the ArduinoISP sketch:
  • Run the Arduino development environment.
  • Open the ArduinoISP sketch from the examples menu.
  • Select the board and serial port that correspond to your Arduino board.
  • Upload the ArduinoISP sketch.
Next we can upload the sketch (program) shown below to the ATtiny:
  • Select “ATtiny45 (w/ Arduino as ISP)” or “ATtiny85 (w/ Arduino as ISP)” from the Tools > Board menu (leave the serial port set to that of your Arduino board).
  • Upload the sketch.
You’ll probably get the following message, but don’t worry, the upload should have worked anyway:

avrdude: please define PAGEL and BS2 signals in the configuration file for part ATtiny85
avrdude: please define PAGEL and BS2 signals in the configuration file for part ATtiny85


If you get an other error, just try again that just might work.

If you did the complete electronics on your breadboard in the previous step, it should work now. This means that if you turn off the lights, than put power on your breadboard, the LED will blink when you shine a light on the sensor. If you push the button, the LED will flash as many times as the sensor was lighted.


The SKETCH (code)

int knopPin = 4;    
int ledPin =  0;     

int knopAan = 0;  
int hoeLicht = 0;
int Verschil = 0;
int Teller = 0;

void setup() {
  pinMode(ledPin, OUTPUT);      
  pinMode(knopPin, INPUT); 
  
  hoeLicht = analogRead(1); // read on the sensor how dark it is  
  Verschil = hoeLicht + 50; // set the sensitivity of the sensor on 50
}

void loop(){
  hoeLicht = analogRead(1);
  if (hoeLicht < Verschil){    //when the sensor is lighted
  digitalWrite(ledPin, LOW);
  }
  else {
    digitalWrite(ledPin, HIGH);
    Teller ++;
    if (Teller > 100){Teller = 99;}
    delay(3000);
    digitalWrite(ledPin, LOW);
    delay(100);
  } 
  knopAan = digitalRead(knopPin); //check the button 
    if (knopAan == LOW) {          //when the button is pushed
    delay(600); //wait till your finger is from the button
  for (int i=1; i <= Teller; i++){ //counting the hits 
  digitalWrite(ledPin, HIGH);
  delay(400);
  digitalWrite(ledPin, LOW);
  delay(400);
  }
    }
}

« Previous StepDownload PDFView All StepsNext Step »

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
23
Followers
8
Author:kenyer(Technisch Speelgoed)
I'm a social-worker, working with 16 - 23 year-olds. I used to be a printer and I worked voluntarily in Romania for a couple of years. One day a week I have a toy-store in technical toys. I have this ...
more »