Converting Attiny45 to a Atmel168?

Has anyone replaced an ATTiny45 with an Atmega168 in order to have addtional I'O's?

Question by ve3poa 10 years ago  |  last reply 10 years ago


PINB register on ATtiny45 not working? Answered

I've been programming a pretty simple led driver in Atmel Studio 6 with the attiny45. The idea is that hitting a push button will advance through three different modes of the LEDs, solid, strobe, and fade. When you reach the last mode hitting the button again should reset to the first mode. For some reason the PINB register doesn't seem to be working. Here is the code: #define F_CPU 1000000 #include #include int main(void) { //  Setup PWM TCCR0A |= (1 << COM0A1) | (1 << WGM00) | (1 << WGM01); TCCR0B |= (1 << CS01); DDRB |= (1 << PB0)|(0< PORTB = 0b00010000;   //enable internal pull up int state = 2;  //initialize some variables while(1) {   //int val = PINB3;       if(PINB == 0)   //if button is pressed, increment state variable   {    _delay_ms(100);   //primitive debouncing...     state = state + 1;   }       if(state > 2){  //if we exceed the number of modes, reset state variable       state = 0;   }else   {    state = state;  //probably not necessary, but has solved problems in the past.   } while(state == 0){   //first mode just turns on LEDs at full brightness     OCR0A = 255; } while(state == 1){  //second mode strobes the LEDs     OCR0A = 255;   _delay_ms(35);   OCR0A = 0;   _delay_ms(35); } while(state == 2){    //Third mode fades LEDs      //  Fade LED on    for(i = 0; i < 255; i++)    {     //  Load new value onto OCR0A register to change duty cycle     OCR0A = i;     _delay_ms(5);    }       //  Fade LED off    for(i = 255; i >= 0; i--)    {     OCR0A = i;     _delay_ms(5);    } } } } All of the independent modes work fine, and even the state variable itself is doing what it is supposed to (I know because initializing it to different values gets me the correct mode) but for some reason the PINB register is not getting any kind of response. I am enabling the internal pull up, and then the button connects the I/0 (in this case PB4) to ground which should make the state zero and satisfy the argument of the if statement, but for some reason this is not doing anything. Any ideas? thanks in advanced!

Question by Higgs Boson 5 years ago  |  last reply 5 years ago


I need a mini-arduino! Help with finding one!

Hey guys! I had a question! I got several ATtiny85s and they were great! I was able to use my Arduino Sketches and my use Arduino to upload the code to them. But now I have a new project and I need more then 2 outputs! I need another microcontroller just like the Attiny85 but with say 4-10 outputs. Any sugggestions? Oh, I have to be able to use my Arduino sketches with it, so I can't use things like the picaxe thingy. I also don't want to buy a miniduino or microduino. Thanks!

Topic by HavocRC 5 years ago  |  last reply 5 years ago


programming a stealth USB caps locker problems? Answered

I have a problem programming my stealth USB caps locker (link)  the PCB is ready, the components soldered on, and ive made connections to my ghetto programmer. now, i opened programmers notepad and wanted to program it, but now it just gives a whole load of errors: > "make.exe" program set -e; avr-gcc -MM -mmcu=attiny45 -I. -g -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=main.lst  -std=gnu99 main.c \     | sed 's,\(.*\)\.o[ :]*,\1.o \1.d : ,g' > main.d; \     [ -s main.d ] || rm -f main.d main.c:19:20: error: usbdrv.h: No such file or directory main.c:20:21: error: oddebug.h: No such file or directory Compiling: main.c avr-gcc -c -mmcu=attiny45 -I. -g -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=main.lst  -std=gnu99 main.c -o main.o In file included from main.c:16: c:/winavr-20090313/lib/gcc/../../avr/include/util/delay.h:85:3: warning: #warning "F_CPU not defined for " main.c:19:20: error: usbdrv.h: No such file or directory main.c:20:21: error: oddebug.h: No such file or directory main.c:25: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'reportBuffer' main.c:26: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'idleRate' main.c:27: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'reportCount' main.c:33: error: 'USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH' undeclared here (not in a function) main.c: In function 'buildReport': main.c:65: error: 'uchar' undeclared (first use in this function) main.c:65: error: (Each undeclared identifier is reported only once main.c:65: error: for each function it appears in.) main.c:65: error: expected ';' before 'key' main.c:68: error: 'reportCount' undeclared (first use in this function) main.c:69: error: 'key' undeclared (first use in this function) main.c:73: error: 'reportBuffer' undeclared (first use in this function) main.c: In function 'timerPoll': main.c:87: error: 'reportCount' undeclared (first use in this function) main.c: At top level: main.c:104: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'usbFunctionSetup' main.c: In function 'calibrateOscillator': main.c:143: error: 'uchar' undeclared (first use in this function) main.c:143: error: expected ';' before 'step' main.c:144: error: expected ';' before 'trialValue' main.c:149: error: 'trialValue' undeclared (first use in this function) main.c:149: error: 'step' undeclared (first use in this function) main.c:150: warning: implicit declaration of function 'usbMeasureFrameLength' main.c:157: error: 'optimumValue' undeclared (first use in this function) main.c: In function 'main': main.c:193: error: 'uchar' undeclared (first use in this function) main.c:193: error: expected ';' before 'i' main.c:194: error: expected ';' before 'calibrationValue' main.c:196: error: 'calibrationValue' undeclared (first use in this function) main.c:200: warning: implicit declaration of function 'odDebugInit' main.c:201: warning: implicit declaration of function 'usbDeviceDisconnect' main.c:202: error: 'i' undeclared (first use in this function) main.c:205: warning: implicit declaration of function 'usbDeviceConnect' main.c:211: warning: implicit declaration of function 'usbInit' main.c:215: warning: implicit declaration of function 'usbPoll' main.c:222: warning: implicit declaration of function 'usbInterruptIsReady' main.c:222: error: 'reportCount' undeclared (first use in this function) main.c:224: warning: implicit declaration of function 'usbSetInterrupt' main.c:224: error: 'reportBuffer' undeclared (first use in this function) make.exe: *** [main.o] Error 1 > Process Exit Code: 2 > Time Taken: 00:03 maybe its this: ""Download capslocker.hex and use AVR Studio or a standalone programming tool to write into the ATTiny45 Flash. Oh, you'll also need to select the fuse for PLL/1k clock source." thats what the maker of this thingie said, but what is the fuse for PLL/1k clock source? could it be that? when i use the .hex file, i get about the same. whats the problem? i didnt change anything.

Question by godofal 9 years ago  |  last reply 9 years ago


Why is the ATtiny85 more expensive than the ATmega328? What? Answered

I only need 2 I/O pins, but if I can get it cheaper with the 328 then why not?  Can anyone find the tiny for under 5 bucks with shipping?

Question by Spaceman Spiff 7 years ago  |  last reply 7 years ago


Attiny 85 not working

HI GUYS. I HAVE A LDR light sensor I would like to use to turn on a light bulb through a attin85. when I upload the sketch to the Arduino it works fine. but when I upload to the attiny, I can't get it to work. am I'm wiring it wrong? when I put my signal from my ldr sensor to AO and 2 to the led it works on Arduino, but when I do that with the Attiny85 it doesn't do anything. The sketch did upload correctly though so it has to be me wiring it wrong or I need to change the code maybe to cater to the attiny85?my sketch is int LDR = 0; int LDRValue = 0; void setup() {pinMode(2, OUTPUT); void loop() { LDRValue = analogRead(LDR); delay(50); if (LDRValue < light_sensitivity) { digitalWrite(2, HIGH); } else { digitalWrite(2, LOW); } }

Question by jman2018 1 year ago  |  last reply 1 year ago


whats the difference between all the 8pin attinys? Answered

I just cant find it, and yet i see  "attiny45" "attiny85" "attiny13" "attiny25" and some others all over the net, theyr all 8pin. what exactly is the difference? and can i use a C++ program for an attiny45 on a attiny13 without modifications? and if not, what do i need to alter? couse i want to make a stealth USB caps lockers (macetech.com/blog/node/46#comment-834) but i only have attiny13 lying around. i also like the blinking, singing, marioman (www.instructables.com/id/Marioman/)  but that also uses a different attiny...

Question by godofal 9 years ago  |  last reply 9 years ago


Storing Simple Analog Data

Hey guys! I just got this cool little temperature (LM35) and I had a small problem. I want to upload this sketch to my ATtiny45 and put it on my plane so I could get the temperature from above. Only problem is I have no way of seeing it. So is there a simple, easy solution to storing a couple of numbers? I though I could just set the temperature every 3 minutes to a variable, but if I turned the board off, the data would be lost. So I don't need to store tons of memory just a couple numbers! Thanks!

Topic by HavocRC 5 years ago  |  last reply 5 years ago


compiler wont compile, cant figure out the errors, help please? Answered

I have a problem programming my stealth USB caps locker (link )  the PCB is ready, the components soldered on, and ive made connections to my ghetto programmer. now, i opened programmers notepad and wanted to program it, but now it just gives a whole load of errors: > "make.exe" program Linking: main.elf avr-gcc -mmcu=attiny45 -I. -g -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=main.o  -std=gnu99 main.o   --output main.elf -Wl,-Map=main.map,--cref -lm main.o: In function `usbFunctionSetup': I:\portableapps\programmers notepad\programma's\CapsLocker/main.c:108: undefined reference to `usbMsgPtr' I:\portableapps\programmers notepad\programma's\CapsLocker/main.c:108: undefined reference to `usbMsgPtr' I:\portableapps\programmers notepad\programma's\CapsLocker/main.c:115: undefined reference to `usbMsgPtr' I:\portableapps\programmers notepad\programma's\CapsLocker/main.c:115: undefined reference to `usbMsgPtr' main.o: In function `main': I:\portableapps\programmers notepad\programma's\CapsLocker/main.c:211: undefined reference to `usbInit' I:\portableapps\programmers notepad\programma's\CapsLocker/main.c:215: undefined reference to `usbPoll' I:\portableapps\programmers notepad\programma's\CapsLocker/main.c:222: undefined reference to `usbTxLen1' I:\portableapps\programmers notepad\programma's\CapsLocker/main.c:224: undefined reference to `usbSetInterrupt' main.o: In function `calibrateOscillator': I:\portableapps\programmers notepad\programma's\CapsLocker/main.c:150: undefined reference to `usbMeasureFrameLength' I:\portableapps\programmers notepad\programma's\CapsLocker/main.c:160: undefined reference to `usbMeasureFrameLength' make.exe: *** [main.elf] Error 1 > Process Exit Code: 2 > Time Taken: 00:01 i believe its a problem with the makefile, but i cant find out what it is anyway. heres the complete zip file: zip file the makefile in that zip doesnt work (for me) so i use one of another program, and with that i get the errors placed above. if you need that makefile, please leave a reply, il try to get it online.

Question by godofal 9 years ago  |  last reply 9 years ago