ATtiny Tester 240506

Hello Arduino forum,

Using the ATtiny more often than the Arduino Uno in projects
that only have few input/outputs because of size and cost.

Because the ATtiny85 is susceptible to EMI and other problems
an ATTiny85 tester was designed and built.
This is a schematic of the ATtiny Tester

This is the schematic applied to a prototype board:

The sketch, copied herewith below, will run
on the ATtiny setup and a similar Arduino Uno
setup without alteration.

The sketch, ,
ATtiny_Tester_240506.ino, copied below, is based on
ATtiny_Tester_230814.ino.
ATtiny_Tester_230814.ino has all of the digitalWrite
statements in the loop() function using the delay() method.
ATtiny_Tester_240506.ino takes the
digitalWrite statements and puts them
in separate runLEDx functions in preparation
for adding the next level of complexity,
using blink w/o delay instead of delay() .
ATtiny_Tester_240507.ino employs
blink w/o delay also here included
below.
Because the simpler version of the sketch
was done eight months ago, when the
blink w/o delay feature was added
today it is wondered why six LEDs
were not used instead of five.

Ot perhaps a better question is:
Can the Reset pin be used for output?

Thanks

Allen Pitts

******* ATtiny_Tester_240506.ino ***********

/*
  ATtiny_Tester_240506.ino
  Turns on five LEDs on for a half a second, then off for one tenth second, repeatedly
  as  a test of the microcontroller. 
  Based on ATtiny_Tester_230814.ino which has all of the digital Write
  statements in the loop() function.
  The internal clock is set to 8 MHZ.
 */

const int ledPin0 = 0;
const int ledPin1 = 1;
const int ledPin2 = 2;
const int ledPin3 = 3;
const int ledPin4 = 4;

// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin 4 as an output.
  pinMode(ledPin0, OUTPUT);
  pinMode(ledPin1, OUTPUT);
  pinMode(ledPin2, OUTPUT);
  pinMode(ledPin3, OUTPUT);
  pinMode(ledPin4, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  runLED0();
  runLED1();
  runLED2();
  runLED3();
  runLED4();
}

void runLED0() {
  digitalWrite(0, HIGH);  // turn the LED on (HIGH is the voltage level)
  delay(500);             // wait for a second
  digitalWrite(0, LOW);   // turn the LED off by making the voltage LOW
  delay(100);             // wait for a .1 second
}

void runLED1() {
  digitalWrite(1, HIGH);  // turn the LED on (HIGH is the voltage level)
  delay(500);             // wait for a second
  digitalWrite(1, LOW);   // turn the LED off by making the voltage LOW
  delay(100);
}
void runLED2() {
  digitalWrite(2, HIGH);  // turn the LED on (HIGH is the voltage level)
  delay(500);             // wait for a second
  digitalWrite(2, LOW);   // turn the LED off by making the voltage LOW
  delay(100);             // wait for a .1 second
}
void runLED3() {
  digitalWrite(3, HIGH);  // turn the LED on (HIGH is the voltage level)
  delay(500);             // wait for a second
  digitalWrite(3, LOW);   // turn the LED off by making the voltage LOW
  delay(100);             // wait for a .1 second
}

void runLED4() {
  digitalWrite(4, HIGH);  // turn the LED on (HIGH is the voltage level)
  delay(500);             // wait for a second
  digitalWrite(4, LOW);   // turn the LED off by making the voltage LOW
  delay(100);             // wait for a .1 second
}

******* ATtiny_Tester_240507.ino ***********

/*
  ATtiny_Tester_240507.ino
  Turns on an five LEDs on and off for five different intervals
  as  a test of the microcontroller. The internal clock is set to 8 MHZ.
  Based on ATtiny_Tester_230506.ino which used a delay method.
  ATtiny_Tester_240507.ino uses blink w/o delay.
  ATtiny_Tester_240507.ino designed to run on schematic
  ATtiny_tester_5_LEDs_schematic_240507.jpg
  and prototype board
  ATtiny_tester_on_Datak_21_114_230812.gif

 */
const int ledPin0 = 0;
const int ledPin1 = 1;
const int ledPin2 = 2;
const int ledPin3 = 3;
const int ledPin4 = 4;

// Variables will change :
int ledState0 = LOW;
int ledState1 = LOW;  // ledState used to set the LED
int ledState2 = LOW;
int ledState3 = LOW;  // ledState used to set the LED
int ledState4 = LOW;

// Generally, you should use "unsigned long" for variables that hold time
// The value will quickly become too large for an int to store
unsigned long previousMillis0 = 0;
unsigned long previousMillis1 = 0;  // will store last time LED was updated
unsigned long previousMillis2 = 0;
unsigned long previousMillis3 = 0;  // will store last time LED was updated
unsigned long previousMillis4 = 0;

// constants won't change :
const long interval0 = 1000;
const long interval1 = 1500;
const long interval2 = 2000;  // interval at which to blink (milliseconds)
const long interval3 = 2500;
const long interval4 = 3000;  // interval at which to blink (milliseconds)

// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin 4 as an output.
  pinMode(ledPin0, OUTPUT);
  pinMode(ledPin1, OUTPUT);
  pinMode(ledPin2, OUTPUT);
  pinMode(ledPin3, OUTPUT);
  pinMode(ledPin4, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  runLED0();
  runLED1();
  runLED2();
  runLED3();
  runLED4();
}

void runLED0() {
  // Compare the difference between the current time and last time
  // the LED oscillated. If the time difference is greater the interval
  // variable, toggle the LED.
  unsigned long currentMillis0 = millis();

  if (currentMillis0 - previousMillis0 >= interval0) {
    // save the last time you blinked the LED
    previousMillis0 = currentMillis0;

    // if the LED is off turn it on and vice-versa:
    if (ledState0 == LOW) {
      ledState0 = HIGH;
    } else {
      ledState0 = LOW;
    }
    // set the LED with the ledState of the variable:
    digitalWrite(ledPin0, ledState0);
  }
}


void runLED1() {
  unsigned long currentMillis1 = millis();

  if (currentMillis1 - previousMillis1 >= interval3) {
    // save the last time you blinked the LED
    previousMillis1 = currentMillis1;

    // if the LED is off turn it on and vice-versa:
    if (ledState1 == LOW) {
      ledState1 = HIGH;
    } else {
      ledState1 = LOW;
    }
    // set the LED with the ledState of the variable:
    digitalWrite(ledPin1, ledState1);
  }
}


void runLED2() {
  unsigned long currentMillis2 = millis();

  if (currentMillis2 - previousMillis2 >= interval2) {
    // save the last time you changed the LED
    previousMillis2 = currentMillis2;

    // if the LED is off turn it on and vice-versa:
    if (ledState2 == LOW) {
      ledState2 = HIGH;
    } else {
      ledState2 = LOW;
    }
    // set the LED with the ledState of the variable:
    digitalWrite(ledPin2, ledState2);
  }
}



void runLED3() {
  // Compare the difference between the current time and last time
  // the LED oscillated. If the time difference is greater the interval
  // variable, toggle the LED.
  unsigned long currentMillis3 = millis();

  if (currentMillis3 - previousMillis3 >= interval3) {
    // save the last time you blinked the LED
    previousMillis3 = currentMillis3;

    // if the LED is off turn it on and vice-versa:
    if (ledState3 == LOW) {
      ledState3 = HIGH;
    } else {
      ledState3 = LOW;
    }
    // set the LED with the ledState of the variable:
    digitalWrite(ledPin3, ledState3);
  }
}

void runLED4() {
  unsigned long currentMillis4 = millis();

  if (currentMillis4 - previousMillis4 >= interval4) {
    // save the last time you blinked the LED
    previousMillis4 = currentMillis4;

    // if the LED is off turn it on and vice-versa:
    if (ledState4 == LOW) {
      ledState4 = HIGH;
    } else {
      ledState4 = LOW;
    }
    // set the LED with the ledState of the variable:
    digitalWrite(ledPin4, ledState4);
  }
}

No, but you can use it as an analog input. as long as you keep the voltage high enough.

A little while ago there was a discussion about using RST as input.

This will print both VCC and the voltage level of the RST pin to the serial monitor.

void setup() {
  Serial.begin(9600);// prints on PB0 as TX
}

void loop() {
  uint16_t VCC = analogReadVCC(); // VCC in milliVolt
  Serial.print("VCC = ");
  Serial.print(VCC);// Prints VCC in milliVolt
  Serial.print(F(" mV \t Reset pin voltage = "));
  Serial.print(analogRead(A0)*(uint32_t) VCC / 1023);
  Serial.println(" mV");
  delay(500);
}

uint16_t analogReadVCC() {
  ADMUX = _BV(MUX3) | _BV(MUX2); // select 1.1V Vref
  delay(2); // Wait for Vref to settle
  ADCSRA |= _BV(ADSC); // Start conversion
  while (bit_is_set(ADCSRA, ADSC)); // measuring
  return 1126400L / ADC;
}

And here is how to connect a potmeter and resistor to the RST pin

Yes, with a high voltage programmer, the reset pin can be set up as a normal I/O pin.

Actually, you can set the fuse to configure the reset pin as a gpio pin without a high voltage programmer. However, having done so, if you ever need to load a new program, you'll need the high voltage programmer to restore the reset pin function.

Is it? More so than other microcontrollers? I never noticed anything particular about it in my projects.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.