Go Down

Topic: Problem trying to programm ATTiny84A  (Read 385 times) previous topic - next topic

glatteis

No he hasn't, I've had this happen as well. He said that programming works now.

ArduinoJ4ck

#16
May 19, 2017, 08:24 pm Last Edit: May 19, 2017, 08:30 pm by ArduinoJ4ck
I think i shortet it :D thats why it heatet up so heavy. But i can still programm it with no errors. Now i found out the pwm and do outputs and find them but i have no idea to find out which pins are analog in, cuz i need them for a bigger sketch. U can find it below. could someone tell me is it possible to get it working with my attiny84A ?
Code: [Select]
#include <EEPROM.h>        // Libary um den EEPROM zu benutzen

int LichtSensor = A0;      // Licht Sensor
int LichtValue = 0;        // Licht Sensor Value
int poti = A1;             // Potentiometer
int LED = 1;              // LED
int opti = A2;             // Obstacle Avoidance Sensor
int promodus = A3;         // Programmier Modus Pin


void setup() {

  Serial.begin(9600);     // Serieellen Monitor starten
  pinMode(A0, INPUT);     // Licht Sensor
  pinMode(A1, INPUT);     // Potentiometer
  pinMode(1, OUTPUT);    // LED
  pinMode(A2, INPUT);     // Obstacle Avoidance Sensor
  pinMode(A3, INPUT);     // Programmier Modus Pin
 
}

void loop() {
  LichtValue = analogRead(A0);   // Lies die LichtValue
  opti = analogRead(A2);         // Lies den Obstacle Sensor
  promodus = analogRead(A3);     // Programmier Modus Pin 

  //Serial.println(LichtValue);
  //Serial.println(poti);
  //Serial.println(promodus);

   if (promodus < 1000)
  {
    EEPROM.get(0, poti);         //Lies aus dem EEPROM
    if (LichtValue > poti)
    {
      digitalWrite(LED, LOW);
    }
    else if (opti < 300)
    {
      digitalWrite(LED, HIGH);
    }
  }
  else
  {
    poti = analogRead(A2);      // Lies den Poti
    EEPROM.put(0, poti);        // Schreib die Poti Value in den EEPROM
    if (LichtValue > poti)
    {
      digitalWrite(LED, HIGH);
    }
    else
    {
      digitalWrite(LED, LOW);
    }
  }


}

 

glatteis

I think i shortet it :D thats why it heatet up so heavy. But i can still programm it with no errors. Now i found out the pwm and do outputs and find them but i have no idea to find out which pins are analog in, cuz i need them for a bigger sketch. U can find it below. could someone tell me is it possible to get it working with my attiny84A ?
Code: [Select]
#include <EEPROM.h>        // Libary um den EEPROM zu benutzen

int LichtSensor = A0;      // Licht Sensor
int LichtValue = 0;        // Licht Sensor Value
int poti = A1;             // Potentiometer
int LED = 1;              // LED
int opti = A2;             // Obstacle Avoidance Sensor
int promodus = A3;         // Programmier Modus Pin


void setup() {

  Serial.begin(9600);     // Serieellen Monitor starten
  pinMode(A0, INPUT);     // Licht Sensor
  pinMode(A1, INPUT);     // Potentiometer
  pinMode(1, OUTPUT);    // LED
  pinMode(A2, INPUT);     // Obstacle Avoidance Sensor
  pinMode(A3, INPUT);     // Programmier Modus Pin
  
}

void loop() {
  LichtValue = analogRead(A0);   // Lies die LichtValue
  opti = analogRead(A2);         // Lies den Obstacle Sensor
  promodus = analogRead(A3);     // Programmier Modus Pin  

  //Serial.println(LichtValue);
  //Serial.println(poti);
  //Serial.println(promodus);

   if (promodus < 1000)
  {
    EEPROM.get(0, poti);         //Lies aus dem EEPROM
    if (LichtValue > poti)
    {
      digitalWrite(LED, LOW);
    }
    else if (opti < 300)
    {
      digitalWrite(LED, HIGH);
    }
  }
  else
  {
    poti = analogRead(A2);      // Lies den Poti
    EEPROM.put(0, poti);        // Schreib die Poti Value in den EEPROM
    if (LichtValue > poti)
    {
      digitalWrite(LED, HIGH);
    }
    else
    {
      digitalWrite(LED, LOW);
    }
  }


}

 
here you go

ArduinoJ4ck

Yeahi was thinking of that 2, but what do i type ?

pinMode(PA1); ?
LichtValue = analogRead(PA1); ?

DrAzzy

#19
May 19, 2017, 11:39 pm Last Edit: May 19, 2017, 11:40 pm by DrAzzy
pinMode(1,INPUT); //this pin is different if using the counterclockwise pinout
LichtValue=analogRead(A1);


See the pinout chart included with the core. Use digital pin number for pinMode(), not analog pin number, as per the warning in the documentation; this limitation will be fixed in a future release.

Note also that pins are set input on powerup, and don't need to be set to INPUT unless they were previously set to something else.
ATtiny core for 841+1634+828 and x313/x4/x5/x61/x7/x8 series Board Manager:
http://drazzy.com/package_drazzy.com_index.json
ATtiny breakouts (some assembled), mosfets and awesome prototyping board in my store http://tindie.com/stores/DrAzzy

ArduinoJ4ck

I just can´t get a potentiometer working.

I connectet the Potentiometer to PA1
The LED is connectet to PB2

The led is slowly glimming but the potentiometer doesn´t do anything to it.
U can find my Code below. Please tell me did i do anything wrong ?
Code: [Select]
  int LED = 2;

void setup() {
  pinMode(2, OUTPUT);
  Serial.begin(9600);
 
}

// the loop routine runs over and over again forever:
void loop() {
 
 
  int Poti = analogRead(A1);
 
  if (Poti > 250)
  {
    digitalWrite(LED, HIGH);
  }
  else
  {
    digitalWrite(LED, LOW);
  }
 
}

Go Up