Scotland
Offline
God Member
Karma: 3
Posts: 513
Have you had your Arduino fix today?
|
 |
« Reply #195 on: June 13, 2012, 12:30:55 pm » |
((reading / 1024) * 5);
reading is 0 ->1024 therefor reading/1024 will be 1 or less (Probably rounded to 1) * 5 = 5, what value range are you trying to get?
|
|
|
|
|
Logged
|
|
|
|
|
Denmark
Offline
God Member
Karma: 19
Posts: 674
|
 |
« Reply #196 on: June 13, 2012, 03:52:02 pm » |
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 4
|
 |
« Reply #197 on: June 13, 2012, 11:54:33 pm » |
Thanks for the link to the tmp36 code. I originally used that code and from project to project it has evolved. My issues, for a reason I am not too sure of, stemmed from not using "float". I toyed with code straight from adafruit's page and found that it broke if I did not float my values. Thank you for your help. I am finished with the coding. Because the "arduino tiny" core was so easy to implement I no longer need to embed 328's for simple projects like this. One final question: Is there an easy way to use the ATtiny85's internal temperature sensor through ArduinoISP? Here is the current completed code (when I embed this I will remove the "serial" functions). const int r = 4;//red const int b = 0;//blue const int g = 1;//green const int s = 1;//sensor *ANALOG
int temp, currentTemp; int previousTemp=0;
long previousMillisTIME= 0; unsigned long intervalTIME = 1000;
void setup(){ Serial.begin(9600); pinMode(r, OUTPUT); pinMode(g, OUTPUT); pinMode(b, OUTPUT); }
void loop(){
unsigned long currentMillisTIME = millis(); if(currentMillisTIME - previousMillisTIME > intervalTIME) { sense(); previousMillisTIME = currentMillisTIME; }
int flick = random(120)+135;//candle like effect
if (temp < 68){//only show blue digitalWrite(r, LOW); digitalWrite(g, LOW); analogWrite(b, flick); } else { if (temp > 72){//only show red digitalWrite(b, LOW); digitalWrite(g, LOW); analogWrite(r, flick); } else {//only show green digitalWrite(b, LOW); digitalWrite(r, LOW); analogWrite(g, flick); } } delay(random(150)); }
void sense(){ delay(10); int reading0 = analogRead(s); delay(10); int reading1 = analogRead(s); delay(10); int reading2 = analogRead(s); delay(10); int reading = ((reading0+reading1+reading2)/3);//average readings float voltage = reading * 3.3;//voltage reference voltage /= 1024.0; float temperatureC = (voltage - 0.5) * 100; float temperatureF = (temperatureC * 9.0 / 5.0) + 32.0; currentTemp = temperatureF; if(currentTemp - previousTemp >= 3) {//hysteresis forward temp = temperatureF; Serial.print("Changed From "); Serial.print(previousTemp); Serial.print(" to "); Serial.println(currentTemp); previousTemp = currentTemp; } else { if(currentTemp - previousTemp <= -3) {//hysteresis backward temp = temperatureF; Serial.print("Changed From "); Serial.print(previousTemp); Serial.print(" to "); Serial.println(currentTemp); previousTemp = currentTemp; } } //debugging Serial.print(voltage); Serial.println(" volts"); Serial.print(temperatureC); Serial.println(" degrees C"); Serial.print(temperatureF); Serial.println(" degrees F"); Serial.print("current reading "); Serial.println(temp); Serial.println(" "); }
|
|
|
|
|
Logged
|
|
|
|
|
London
Offline
Full Member
Karma: 0
Posts: 146
Ugi was not declared in this scope
|
 |
« Reply #198 on: June 23, 2012, 03:31:11 am » |
I'm trying to use the ATtiny85 Arduino Tiny core in a project where I need to use the 2.56v internal reference for the ADC - not least because I need the ARef pin for other things, but also so that the reading is not directly dependent upon VCC, which in a battery powered situation is not very uniform. I appreciate that we need to use the non-decoupled 2.56v to avoid connecting pin 5 to that voltage.
I have tried poking at ADMUX without success and wondered:
Does analogRead always use the external Vref? If so, can I read ADCL & ADCH directly? I have tried but seem to be getting zeros.
Any thoughts appreciated.
Edit - it appears that by poking ADMUX I can alter the reference voltage (I can set it so that the 2.5v appears at PB0) but as soon as I call AnalogRead it reverts to the external ref.
|
|
|
|
« Last Edit: June 23, 2012, 03:39:51 am by Dr_Ugi »
|
Logged
|
|
|
|
|
|
|
London
Offline
Full Member
Karma: 0
Posts: 146
Ugi was not declared in this scope
|
 |
« Reply #200 on: June 23, 2012, 06:31:57 am » |
That's fantastic - I would not have believed that I could have learned quite so much from such a short reply!
I did have a hunt through the source code for the tiny core but didn't find anytihng, but it would have taken me a while to get around to looking in wiring.h
I suppose INTERNAL2v56NB (for no bypass) is as logical as anything but you will have a much better feel for that than me.
I do think this is a useful reference to have because, with so few pins, if you want an absolute measurement but are not too worried about accuracy then you might prefer to avoid giving a pin up to a capacitor.
Thanks again
|
|
|
|
|
Logged
|
|
|
|
|
Wisconsin
Offline
God Member
Karma: 4
Posts: 994
I LOVE THIS STUFF!!!!
|
 |
« Reply #201 on: June 23, 2012, 08:06:18 am » |
unfortunately I'm getting a not in sync error when using these cores when trying to bootload. resp 0x00
|
|
|
|
|
Logged
|
Accelerate to 88 miles per hour.
|
|
|
|
Dallas, Texas
Offline
God Member
Karma: 1
Posts: 690
Old, decrepit curmugeon
|
 |
« Reply #202 on: June 23, 2012, 09:41:58 am » |
unfortunately I'm getting a not in sync error when using these cores when trying to bootload. resp 0x00
In order to help, you will need to supply some more information. - What version of the IDE are you using?
- What chip are you attempting to program?
- What device are you using to do the programming?
- Turn on verbose programming and provide a complete copy of the output
- How are you connecting the device to the programmer? Picture helpful.
|
|
|
|
|
Logged
|
|
|
|
|
Wisconsin
Offline
God Member
Karma: 4
Posts: 994
I LOVE THIS STUFF!!!!
|
 |
« Reply #203 on: June 23, 2012, 03:32:17 pm » |
I'm using Arduino IDE 1.0.1 ATtiny45 @ 8 ArduinoISP (Arduino Duemilanove) I don't know how to turn on verbose programming Here is a video of the whole deal, It starts out dark so you can see the TX and RX leds and then it shows my setup
|
|
|
|
|
Logged
|
Accelerate to 88 miles per hour.
|
|
|
|
Dallas, Texas
Offline
God Member
Karma: 1
Posts: 690
Old, decrepit curmugeon
|
 |
« Reply #204 on: June 23, 2012, 03:43:42 pm » |
Verbose programming can be turned on use File | Preferences
|
|
|
|
|
Logged
|
|
|
|
|
Wisconsin
Offline
God Member
Karma: 4
Posts: 994
I LOVE THIS STUFF!!!!
|
 |
« Reply #205 on: June 23, 2012, 03:46:57 pm » |
C:\Users\shannon\Desktop\arduino-1.0.1\hardware/tools/avr/bin/avrdude -CC:\Users\shannon\Desktop\arduino-1.0.1\hardware/tools/avr/etc/avrdude.conf -v -v -v -v -pattiny45 -cstk500v1 -P\\.\COM6 -b19200 -e -Uefuse:w:0xFF:m -Uhfuse:w:0xD7:m -Ulfuse:w:0xE2:m
avrdude: Version 5.11, compiled on Sep 2 2011 at 19:38:36 Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/ Copyright (c) 2007-2009 Joerg Wunsch
System wide configuration file is "C:\Users\shannon\Desktop\arduino-1.0.1\hardware/tools/avr/etc/avrdude.conf"
Using Port : \\.\COM6 Using Programmer : stk500v1 Overriding Baud Rate : 19200 avrdude: Send: 0 [30] [20] avrdude: Send: 0 [30] [20] avrdude: Send: 0 [30] [20] avrdude: Recv: avrdude: stk500_getsync(): not in sync: resp=0x00
avrdude done. Thank you.
|
|
|
|
|
Logged
|
Accelerate to 88 miles per hour.
|
|
|
|
California
Offline
Sr. Member
Karma: 2
Posts: 408
|
 |
« Reply #206 on: August 04, 2012, 03:55:39 am » |
I want to use an attiny84 for some speed/timing stuff at 3v. The internal oscillator is pretty lousy, can I use a 1MHz external crystal? And if so, what pins are for the crystal on the 84?
Thanks
|
|
|
|
|
Logged
|
|
|
|
|
Leeds, UK
Offline
God Member
Karma: 35
Posts: 980
Once the magic blue smoke is released, it won't go back in!
|
 |
« Reply #207 on: August 04, 2012, 05:58:56 am » |
The XTAL pins are on physical pins 2 and 3 (PB0 and PB1). You would have to change the boards.txt file to use the correct freqency. There is an entry for 84 with a 16MHz external crystal, just copy and paste this, change the name and set the freqency to 1000000
|
|
|
|
|
Logged
|
~Tom~
|
|
|
|
Italy
Offline
Brattain Member
Karma: 219
Posts: 16431
Don't know what I do
|
 |
« Reply #208 on: September 24, 2012, 04:17:48 am » |
I've noticed that digitalWrite isn't available inside the setup(). Why?
EDIT: forget about it
|
|
|
|
« Last Edit: September 24, 2012, 04:57:48 am by leo72 »
|
Logged
|
|
|
|
|
Denmark
Offline
God Member
Karma: 19
Posts: 674
|
 |
« Reply #209 on: September 24, 2012, 04:43:05 am » |
for (byte temp = 0; temp++; temp < 4) { should be: for (byte temp = 0; temp < 4;temp++) {
|
|
|
|
|
Logged
|
|
|
|
|
|