Pages: 1 ... 11 12 [13] 14 15 ... 22   Go Down
Author Topic: Arduino Tiny  (Read 61033 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 4
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm enjoying Arduino Tiny.  Thanks alot for this cool set of cores. I'm only using the ATTiny85 right now, but look forward to trying out others.
There is one thing I can't wrap my head around. I am trying to read a voltage from ADC2 /PB4 / IC pin #3. To read the value I use :
Code:
int value = analogRead(2);
but if I wanted to use it as a digital input I would use
Code:
int value = digitalRead(4);
The arduino standard pin has alias constants A0=14 so you use:
Code:
int value = analogRead(A0);
But behind the scenes the pin number is different since A0 is really 14.  Why is the pin number "2" overloaded in this case?

This is such a cool set of cores, you should have your own forum instead of this thread. Also, opening that wiki a little might be nice. There are some basic head slap errors that could be put in a frequent problems.

Thanks alot,
Marc
Logged

Global Moderator
Dallas
Online Online
Shannon Member
*****
Karma: 208
Posts: 12937
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm enjoying Arduino Tiny.

Excellent.  I'm glad.

Quote
I am trying to read a voltage from ADC►2◄ /PB4 / IC pin #3. To read the value I use :
int value = analogRead( ►2◄ );

The Uno and boards like it have the same numbering pattern for analog inputs.

Quote
but if I wanted to use it as a digital input I would use
int value = digitalRead( ►4◄ );

PB►4◄

Open the datasheet...
http://www.atmel.com/devices/attiny85.aspx?tab=documents
...navigate to...
1. Pin Configurations

"ADC" for analog "pins".  "PB" for digital "pins".  The numbering pattern makes it much easier to go from functional descriptions in the datasheet to code.

Quote
This is such a cool set of cores,

Thanks.  The next version will be much better (if I ever finish it).

Quote
you should have your own forum instead of this thread

That is very unlikely to happen.  Moderating one forum is enough.

Quote
Also, opening that wiki a little might be nice.

That wiki irritates me to no end.  What is there is probably all that will ever be there.  I have another one started at another location that will eventually be made available to the public.

I am certainly will to give you (or anyone else) wiki edit permission if you'd like.
Logged

SE USA
Offline Offline
Faraday Member
**
Karma: 41
Posts: 3783
@ssh0le
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

raises hand for wiki edit
Logged


0
Offline Offline
Newbie
*
Karma: 0
Posts: 4
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

"ADC" for analog "pins".  "PB" for digital "pins".  The numbering pattern makes it much easier to go from functional descriptions in the datasheet to code.

I think I see your point.  I understand the pin diagram and that in this case a better description of the two functions in this core might be analogRead(ADC#) and digitalRead(port B position). I just want to know if understand that this scheme is different than how the arduino code base identifies "pins". As far as I can tell each physical pin is always identified using the same integer regardless of if it is a digit read from the port, or an analog read from the ADC. Whereas, this core distinguishes port positions from the ADCs uses the integer value 2 for two different physical pins.

Quote
That is very unlikely to happen.  Moderating one forum is enough.
I just mean that there are several troubleshooting topics interwoven in this one thread. It might be nice to have a sub category to Microcontrollers, which you are already moderating, just for Tiny Arduino. It might encourage questions to be broken up into individual threads. There is clearly a lot of interest.

Quote
I am certainly will to give you (or anyone else) wiki edit permission if you'd like.
That would be great. Most of my inclusions would just be the simple mistakes I was having using the Arduino as programmer. MISO/MOSI wired wrong etc...
Logged

Global Moderator
Dallas
Online Online
Shannon Member
*****
Karma: 208
Posts: 12937
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

raises hand for wiki edit

Excellent.  Looks like you will need a "Google Account".  I think that just means signing up for a GMail.com email address.  Personal Message me the email address and I'll set you up.
Logged

Global Moderator
Dallas
Online Online
Shannon Member
*****
Karma: 208
Posts: 12937
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I just want to know if understand that this scheme is different than how the arduino code base identifies "pins". As far as I can tell each physical pin is always identified using the same integer regardless of if it is a digit read from the port, or an analog read from the ADC.

That is not correct.  On the Uno, digital pins 14 through 19 correspond to analog pins 0 through 5.  The A* constants hide that fact.

Quote
Whereas, this core distinguishes port positions from the ADCs uses the integer value 2 for two different physical pins.

Correct.

Quote
I just mean that there are several troubleshooting topics interwoven in this one thread.

Yup.  It's a gnarly mess.

Quote
It might be nice to have a sub category to Microcontrollers, which you are already moderating, just for Tiny Arduino.

That is very unlikely to happen.  The moderators do not have the power to create subcategories and I doubt the administrators will have much interest.  This is an Arduino forum.   smiley-wink

Quote
That would be great.

See the post above.
Logged

California
Offline Offline
Sr. Member
****
Karma: 3
Posts: 433
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

After I upload my sketch to the attiny85 everything works fine until I disconnect the attiny from the arduino pin 13. Then it stops and when I plug it back in it acts all nutty. I tried powering everything down, unplugging then powering up and I got the same thing. What could be going on here? Same thing with a few different attinys.

nevermind sorry, wiring issue.
« Last Edit: May 13, 2012, 01:50:28 am by stoopkid » Logged

0
Offline Offline
Newbie
*
Karma: 1
Posts: 9
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello All,

Just wanted to thank everyone in this thread for the useful tidbits of info.

Solarbotics has just released an ATtiny85 application board that takes advantage of all this good stuff.

The SB-Firefly can be found here: http://www.solarbotics.com/product/60140/
Logged

London
Offline Offline
Full Member
***
Karma: 0
Posts: 146
Ugi was not declared in this scope
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Not sure if this is the place to ask, but I have been programing my ATtiny85s with the Arduino Tiny core using my nano as ISP.  All works great.

However, I only have one "real" Arduino and so I thought I would make a small programmer using a '328 breakout board and an 8-pin DIL socket.  I have checked the connections loads of times and I see the heartbeat from the Arduino ISP sketch but for some reason I get this error when I program using my stand-alone clone:

avrdude: stk500_paged_write(): (a) protocol error, expect=0x14, resp=0x64

I can only think of two possibly significant differences between my clone and a "real" arduino:  

I am using an ATMega328 not a '328P (it is bootloaded correctly with the Duemilanove bootloader).
I am using a CP2102 type USB to serial converter.

There is no auto-reset capacitor on my clone board so disabling auto-reset should not be an issue.

Anyone have any ideas why I'm getting this problem?
Logged

Denmark
Offline Offline
Edison Member
*
Karma: 35
Posts: 1073
Happy Hobbyist
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Coud it be the different device signature in P vs non P

http://arduino.cc/forum/index.php/topic,98956.0.html
Logged

London
Offline Offline
Full Member
***
Karma: 0
Posts: 146
Ugi was not declared in this scope
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You could be right, and certainly in order to bootload the '328 I needed to tweak the .config file for AVRdude.  However, once the bootloader is installed they usually function in the same way.

I do have a '328P knocking around somewhere but I need to bootload that before I can try it out.  Ho Hum.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have been banging my head into the wall tying to make a temperature candle out of the Tiny85. I originally tried using the MIT core, but was unable to use PB4 as a PWM.  Changing to the "arduino tiny" library enable the use of PB4 as a PWM. I am also trying to use a TMP36 sensor to adjust an RGB led based on the temperature. I am not committed to using this sensor; I chose it because of size (smt) and cost (around $1). I have searched high and low on how to make the tiny read this sensor. I cannot get "analogRead" to function properly. If someone can point me in the right direction. I would be grateful. I would really like to try using the internal temperature sensor, but could find no code examples I could understand. Here is my code. Suggestions appreciated.

Code:
const int REDLITE = 0;
const int BLUELITE = 4;
const int GREENLITE = 1;

int flick, temp, tempC, voltage, reading;

void setup(){
  Serial.begin(9600);
  pinMode(REDLITE, OUTPUT);
  pinMode(GREENLITE, OUTPUT);
  pinMode(BLUELITE, OUTPUT);
}

void loop(){
     reading = analogRead(1); 
     voltage = ((reading / 1024) * 5);
     tempC = (voltage - 0.5) * 100 ;
     temp = tempC;
     Serial.println(temp);

  flick = random(120)+135;

  if (temp < 23){
    digitalWrite(REDLITE, LOW);
    digitalWrite(GREENLITE, LOW);
    analogWrite(BLUELITE, flick);
  }
  else {
    if (temp > 30){
      digitalWrite(BLUELITE, LOW);
      digitalWrite(GREENLITE, LOW);
      analogWrite(REDLITE, flick);
    }
    else {
      digitalWrite(BLUELITE, LOW);
      analogWrite(REDLITE, flick);
      analogWrite(GREENLITE, flick);
    }
  }
  delay(random(100));
}
Logged

Global Moderator
Dallas
Online Online
Shannon Member
*****
Karma: 208
Posts: 12937
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I cannot get "analogRead" to function properly.

 ?  


Quote
reading = analogRead(1);  

...is PB2.  Is the sensor connected to the second pin down on the right side?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The sensor is hooked up to the second pin down on the right side (pin #7). The attiny85 does not respond to the tmp36. When the chip is powered up the blue led flickers. Assuming I have the serial function set correctly the pin continuously resturns "-50" regardless of the conditions I place upon the sensor; breathing on the sensor, pulling the sensor out, or using a potientiometer/voltage divider offers no reaction. I even tried using using a different sensor, with no change in behavior. I do not know what is going on because even changing to a different pin does not fix this. Any suggestions?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

After removing all of the temperature calculation and substituting the sensor for a 10k pot I am able to affect the color of the LED. Is there something wrong with my temp formula? The serial returns values from 0-1023 when I am not using the formula. When I try and calculate the temperature the serial port always returns -50. I have used the temp code on the 328's without issue. Any idea what is going on?

Code:
const int REDLITE = 4;
const int BLUELITE = 0;
const int GREENLITE = 1;

int flick, reading;

void setup(){
  Serial.begin(9600);
  pinMode(REDLITE, OUTPUT);
  pinMode(GREENLITE, OUTPUT);
  pinMode(BLUELITE, OUTPUT);
}

void loop(){
  reading = analogRead(1);  
  Serial.println(reading);
  flick = random(120)+135;

  if (reading < 235){
    digitalWrite(REDLITE, LOW);
    digitalWrite(GREENLITE, LOW);
    analogWrite(BLUELITE, flick);
  }
  else {
    if (reading > 280){
      digitalWrite(BLUELITE, LOW);
      digitalWrite(GREENLITE, LOW);
      analogWrite(REDLITE, flick);
    }
    else {
      digitalWrite(BLUELITE, LOW);
      analogWrite(REDLITE, flick);
      analogWrite(GREENLITE, flick);
    }
  }
  delay(random(100));
}
« Last Edit: June 13, 2012, 07:46:55 pm by lightningserpent » Logged

Pages: 1 ... 11 12 [13] 14 15 ... 22   Go Up
Jump to: