Playing with the ATtiny10 (blink interval based on ADC)

I am trying, with on my desk in sight the ATtiny10 complete datasheet, to write a program to blink a led with an interval based on the value from a free running ADC. I left the setting which I commented out, just to show what I did and where I decided something was not necessary.

#include <avr/io.h>
#include <util/delay.h>

// #define F_CPU 8000000UL      // defines CPU speed - actual speed is set using CLKPSR in main()
#define F_CPU 1000000UL         // defines CPU speed - in this case standard prescaling (/8)

#define controlPort PORTB
#define ledPin 1                // = Pin 3
#define outPin 2                // = Pin 4
#define inPin 3                 // = Pin 6
#define freqPin 0               // = Pin 1

unsigned int adcValue = 0;      // Creates a variable for storing the ADC output

int main(void)
  // Set CPU speed by setting clock prescaler
  // CCP = 0xD8;                // CCP register must first be written with the correct signature - 0xD8
  // CLKPSR = 0x00;             // CLKPS[bits 3:0] sets the clock division factor, in this case to 1 (0000 = no devision)

  // Defines in- & outputs
  DDRB = 0x06 ;                 // Sets PB1 and PB2 to output, remaining stay input
  controlPort = 0x00 ;          // Sets all outputs low
  // ADMUX = 0x00;              // Sets PB0 to analog input (already 0x00 at reset)
  // ADCSRB = 0x00;             // Setting ADC to free running without interrupt (already 0x00 at reset)
  ADCSRA = 0xC0;                // Enables and start the ADC
  // PRR = 0x00;                // (already 0x00 at reset)
  DIDR0 - 0x07;                 // Disables digital input buffer on analog input and digital outputs

  while (1)
    controlPort = 0x02 ;
    controlPort = 0x00 ;

void delay_us(int adcValue)
  adcValue = ADCL;
  int delayTimer;
  for (delayTimer = 0; delayTimer < adcValue; delayTimer++) {

Do you have a question?


The _delay_ms() functions from avr-libc must be used with a compile-time constant as an argument.

You define

void delay_us(int adcValue) {
  adcValue = ADCL;

But you don't call it from anywhere. You also immediately overwrite the argument passed in, which is wrong. And delaying for an 8bit ADC value worth of microseconds will give you less than a millisecond, which would be imperceptible as "blinking" on an LED.
(in fact, even delaying for an ADC worth of milliseconds is likely to be to mostly not useful.)
And you should use symbolic names for the bits in ADCSRA

You should define F_CPU before including <util/delay.h>.
Otherwise a default value of 1 MHz is used for delay calculations.