ATTiny85

This is a first experiment burning an Arduino sketch into an ATTiny85 microcontroller. This time we will have an analog input which will control an analog output.

Step by step you should:

  1. Upload Arduino as ISP sketch into your Arduino UNO or similar
  2. Connect everything
  3. "Burn Arduino"
    1. Fuses are set
    2. flash ArduinoBootloader
    3. Select programmer "Arduino as ISP"
    4. Upload using programmer
  4. Upload your sketch using programmer.

According with the ATTiny85's pinout schematic

 

download.png

We have 5 digital pins (blue ones) and 3 analog pin (red ones) which is enough for our little example. Let put a force resistor (analog input 0 - 1023) in order to control a fading LED (which receives 0 - 255).

 

WhatsApp Image 2018-02-01 at 9.18.17 AM.jpeg
//ARDUINO CODE
int led = 1;           // the PWM pin the LED is attached to
int forceR = A1;        // Pin 2 = A1 according to pinout
int force;
// the setup routine runs once when you press reset:
void setup() {
  // declare pin 9 to be an output:
  pinMode(led, OUTPUT);
}

// the loop routine runs over and over again forever:
void loop() {
  force = analogRead(forceR);
  brightness = map(force, 0, 1023, 0, 255);
  // LED gets brighter the harder you press
  analogWrite(led, brightness);

}