ATTiny2313 Pin help

Hi All,

I am trying to put the fallowing code on to an ATTiny2313 (or 84). I Can burn it to the chip. But I am not sure what to renumber the pins to.

Any help is welcome.

Thanks

-KC

#define msg7RESET 11
#define msg7Strobe 10
#define msg7DCout 0
const int LEDpins[7] = {1,2,4,7,8,12,13}; // there are 5 LEDs and 7 freq bands. So, repeat LEDs

#define pushButton 2

void setup() {
  // initialize the digital pin as an output.
  // Pin 13 has an LED connected on most Arduino boards:
  for (int x=0; x<7; x++) {
    pinMode(LEDpins[x], OUTPUT);
  }
  pinMode(msg7RESET, OUTPUT);
  pinMode(msg7Strobe, OUTPUT);

  pinMode(pushButton, INPUT); // never actually used in this example.
  digitalWrite(pushButton, HIGH); // Enable internal pull-up
}

void loop() {
  digitalWrite(msg7RESET, HIGH); // reset the MSGEQ7?s counter
  delay(5);
  digitalWrite(msg7RESET, LOW);

  for (int x = 0; x < 7; x++){
    digitalWrite(msg7Strobe, LOW); // output each DC value for each freq band
    delayMicroseconds(35); // to allow the output to settle
    int spectrumRead = analogRead(msg7DCout);

    int PWMvalue = map(spectrumRead, 0, 1025, 0, 255); // scale analogRead’s value to Write’s 255 max
    if (PWMvalue < 50)
      PWMvalue = PWMvalue / 2; // bit of a noise filter, so the LEDs turn off at low levels

    analogWrite(LEDpins[x], PWMvalue);
    digitalWrite(msg7Strobe, HIGH);
  }
}

Start with the documents for the ATtiny core you are using. There should be a diagram or chart showing which ATtiny pins map to which Ardino pins.

Are you using one of these cores of something else?

http://code.google.com/p/arduino-tiny/

http://hlt.media.mit.edu/?p=1695

int spectrumRead = analogRead(msg7DCout);

The t2313 does not have an analog-to-digital convert.

johnwasser: Are you using one of these cores of something else?

http://code.google.com/p/arduino-tiny/

I believe I am using the one listed above. I can program the chip and I have tested it with the Blink sketch and it works fine.

But when I put my code one it i get nothing.

[quote author=Coding Badly link=topic=182239.msg1350366#msg1350366 date=1376267005]

int spectrumRead = analogRead(msg7DCout);

The t2313 does not have an analog-to-digital convert. [/quote]

Well thats not good. Do you know what Attiny I would be able to use.

Also thanks for the info.

-kc

If it has enough pins the t84 should work.

Thanks

Ok I got it to load to an At84 and it works, kind of.

The Code is for an light organ. When I play music the LED flash as programed. The issue is when no music is playing,
led’s 1-5 glow.

Any Ideas.

Here Is my code with changes.

#define msg7RESET 8
#define msg7Strobe 9
#define msg7DCout 0
const int LEDpins[7] = {1,2,3,4,5,6,7}; // there are 7 LEDs and 7 freq bands.

#define pushButton 2

void setup() {
  // initialize the digital pin as an output.
  // Pin 13 has an LED connected on most Arduino boards:
  for (int x=0; x<7; x++) {
    pinMode(LEDpins[x], OUTPUT);
  }
  pinMode(msg7RESET, OUTPUT);
  pinMode(msg7Strobe, OUTPUT);

  pinMode(pushButton, INPUT); // never actually used in this example.
  digitalWrite(pushButton, HIGH); // Enable internal pull-up
}

void loop() {
  digitalWrite(msg7RESET, HIGH); // reset the MSGEQ7?s counter
  delay(5);
  digitalWrite(msg7RESET, LOW);

  for (int x = 0; x < 7; x++){
    digitalWrite(msg7Strobe, LOW); // output each DC value for each freq band
    delayMicroseconds(35); // to allow the output to settle
    int spectrumRead = analogRead(msg7DCout);

    int PWMvalue = map(spectrumRead, 0, 1025, 0, 255); // scale analogRead’s value to Write’s 255 max
    if (PWMvalue < 50)
      PWMvalue = PWMvalue / 2; // bit of a noise filter, so the LEDs turn off at low levels

    analogWrite(LEDpins[x], PWMvalue);
    digitalWrite(msg7Strobe, HIGH);
  }
}

You have the MSGEQ7 output connected to which physical pin on the t84?

[quote author=Coding Badly link=topic=182239.msg1350485#msg1350485 date=1376285505]

You have the MSGEQ7 output connected to which physical pin on the t84?

[/quote]

define msg7RESET 8 Pin 7

define msg7Strobe 9 Pin 4

define msg7DCout 0 Pin 3

None of those look correct…
http://code.google.com/p/arduino-tiny/source/browse/cores/tiny/pins_arduino.c#162

[quote author=Coding Badly link=topic=182239.msg1350519#msg1350519 date=1376289602]

None of those look correct... http://code.google.com/p/arduino-tiny/source/browse/cores/tiny/pins_arduino.c#162

[/quote]

I take it The (D's) stand for Digital. If so Doesn't the *$ have any Analog ![](http://forum.arduino.cc// ATMEL ATTINY84 / ARDUINO

//

// +-\/-+

// VCC 1| |14 GND

// (D 0) PB0 2| |13 AREF (D 10)

// (D 1) PB1 3| |12 PA1 (D 9)

// PB3 4| |11 PA2 (D 8)

// PWM INT0 (D 2) PB2 5| |10 PA3 (D 7)

// PWM (D 3) PA7 6| |9 PA4 (D 6)

// PWM (D 4) PA6 7| |8 PA5 (D 5) PWM

// +----+)

Yes.

The analog inputs are on port A (PA0 through PA7). The number (e.g. PA1) is the parameter for analogInput (e.g. 1).

[quote author=Coding Badly link=topic=182239.msg1351101#msg1351101 date=1376328693]

Yes.

The analog inputs are on port A (PA0 through PA7). The number (e.g. PA1) is the parameter for analogInput (e.g. 1).

[/quote]

The Code I am using calls for 9 Digital Pins and 1 Analog pin. This is what I am using.

Physical Pin# ON Tiny84 Connected to : 3 (D1) LED 5 (D2) LED 6 (D3) LED 7 (D4) LED 8 (D5) LED 9 (D6) LED 10 (D7) LED 11 (D8) MSGEQ7 Reset PIN 7 12 (D9) " " Strobe Pin 4 13 (AO) " " OUT Pin 3

Am I doing somthing wrong ?

-KC

I Think I know whats going on.

If I unplug the strobe pin (Pin 4 on the Eq7 ) and just let it sit it the LED's go dark. if I just put my hand by the jumper the LED flicker.

kculm: Am I doing somthing wrong ?

Looks correct.

kculm: If I unplug the strobe pin (Pin 4 on the Eq7 ) and just let it sit it the LED's go dark. if I just put my hand by the jumper the LED flicker.

Sounds like your sketch is not correctly interacting with the MSGEQ7. For a simple test you could replace the MSGEQ7 with a potentiometer (voltage divider). If adjusting the voltage has the desired affect then you can be certain the problem is the interface between the t84 and the MSGEQ7.

[quote author=Coding Badly link=topic=182239.msg1351525#msg1351525 date=1376359462]

Sounds like your sketch is not correctly interacting with the MSGEQ7. For a simple test you could replace the MSGEQ7 with a potentiometer (voltage divider). If adjusting the voltage has the desired affect then you can be certain the problem is the interface between the t84 and the MSGEQ7.

[/quote]

Sorry to be a pain, but could you tell me what Pin on the MSGEQ7 I would use.

Please and Thanks

Hi Keith,

It looks like you have the ATTiny84 connections sorted as per reply #13

kculm: Sorry to be a pain, but could you tell me what Pin on the MSGEQ7 I would use.

For a very easy to follow write-up to check your work on the MSGEQ7 side, check out this tutorial by John Boxall.

Cheers ! Geoff

Geoff,

I think you may of misunderstood me.

I Can get it to work fine if I use the uno. it is when I put it on the at84 it gets buggy.

I was going to test as advised

(For a simple test you could replace the MSGEQ7 with a potentiometer (voltage divider). If adjusting the voltage has the desired affect then you can be certain the problem is the interface between the t84 and the MSGEQ7.)

I was not sure of how to do that. I will take a look at the link you sent me.

And thanks for you input.