Show Posts
Pages: [1] 2 3 ... 26
1  Using Arduino / Microcontrollers / Re: Strange problem w/ ATTiny85 (MOSI/MISO interference) on: September 19, 2014, 04:11:09 pm
Thanks guys, I really like idea of high power ISP programmer, I'm gonna try building one.

Just use your Uno.

Why? I like USBTiny ISP smiley   Does UNO provide higher voltage?
BTW, for some reason USBTiny won't program ATTiny85 SOIC version unless I have power jumper on. It does program ATTiny85 thru the hole version tho without extra power...
2  Using Arduino / Microcontrollers / Re: Strange problem w/ ATTiny85 (MOSI/MISO interference) on: September 19, 2014, 02:26:05 pm
Oooh , new replies! I wonder why I stopped receiving notifications, I'm still subscribed smiley
Thanks guys, I really like idea of high power ISP programmer, I'm gonna try building one.
Yeah adding any kind of extra switch or programming chip off board is challenging since size of this device is tiny. Here's a video of my digital butterfly in action smiley
http://youtu.be/vHJWW2OlcNU
3  Using Arduino / Microcontrollers / Re: Strange problem w/ ATTiny85 (MOSI/MISO interference) on: September 17, 2014, 09:45:01 pm
Thanks! Oh well I might try that once I iron out the code smiley  All components I'm using SMD, so it's a pain to solder/desolder resistor each time  I need to reprogram chip smiley
BTW, I was wrong about 6 LEDs, looks like I can still control 10!
4  Using Arduino / Microcontrollers / Strange problem w/ ATTiny85 (MOSI/MISO interference) on: September 17, 2014, 07:44:16 pm
I built small LED badge powered by coin cell and Attiny85 SOIC chip.
It's charlieplexing setup with 4 pins driving 12 LEDs. However after I soldered everything I wasn't able to program processor, was getting invalid signature error. So I soldered another board, adding one component at time. Long story short, I found issue is cased by Resistor/LED that's between MOSI and MISO lines (pins 5 and 6). I'm using USBTiny ISP to program chip from Arduino IDE environment. Everything works when I remove that resistor (R7), but that only gives me 6 LEDs instead of 12. Is there anything that can be done, and why is this happening? I'm attaching schematics if that helps...
5  Using Arduino / Programming Questions / Re: Expected unqualified-id before 'else' error on: September 09, 2014, 02:08:47 pm
Sorry about confusion...
It's a macro inside LED_2416.cpp (matrix driver library). I didn't write it.  
It supposed to translate Arduino pin numbers into hardware pins thus making digitawrites 100x faster. And it works, I just couldn't get this Macro to compile for some reason.
"/" are meant to be carryover to next line, without them whole thing will need to be written on single line.
And basically syntax is correct. If I make into a function (i.e. "void fWriteB(byte pin, byte val) ") it compiles, but doesn't give me fast pin write effect for some reason.  C++ macros apparently have their own syntax, and this is too advanced for me at this point smiley-sad
Fortunately I finally found substitution macro that works:
Code:
//Atmega328 Version of fastWrite - for pins 0-13
#define fWrite(_pin_, _state_) ( _pin_ < 8 ? (_state_ ?  PORTD |= 1 << _pin_ : \
PORTD &= ~(1 << _pin_ )) : (_state_ ?  PORTB |= 1 << (_pin_ -8) : PORTB &= ~(1 << (_pin_ -8)  )))

P.S. I'm writing sketch for my wearable LED display (w/ dual 24x16 LEDs) that I plan to show off at Maker's fair.  It was working fine with my ATMega1284p board, but that was too big to fit inside the case, so I'm rewriting it to run off small ATMega328 board.  I was stuck on this fastwrite for a while, thus my question. But it's good now!  Thank you all! smiley


All the # statements need to be at the top of the sketch.



Nope, #defines can show up anywhere, but they will only be visible to code below it in the file, which can be problematic on the arduino since it munges files together.
I think you both right. In main sketch it should be at the top, but if you including external library (like in my case), that library can have it anywhere.
6  Using Arduino / Audio / Re: Real time MIDI w/ music shield on: September 09, 2014, 01:04:31 pm
Glad you got it working! smiley
7  Using Arduino / Programming Questions / [RESOLVED] Expected unqualified-id before 'else' error on: September 09, 2014, 12:55:37 pm
I'm stuck on this error, have no clue why it's happening, syntax seems to be correct, all braces are in right places...
Code:
#define fWrite(pin, val) if (val) switch (pin) {     \
    case 0: PORTD |= 1<<0; break;       \
    case 1: PORTD |= 1<<1; break;       \
    case 2: PORTD |= 1<<2; break;       \
    case 3: PORTD |= 1<<3; break;       \
    case 4: PORTD |= 1<<4; break;       \
    case 5: PORTD |= 1<<5; break;       \
    case 6: PORTD |= 1<<6; break;       \
    case 7: PORTD |= 1<<7; break;       \
    case 8: PORTB |= 1<<0; break;       \
    case 9: PORTB |= 1<<1; break;       \
    case 10: PORTB |= 1<<2; break;      \
    case 11: PORTB |= 1<<3; break;      \
    case 12: PORTB |= 1<<4; break;      \
    case 13: PORTB |= 1<<5; break;      \
    } else switch (pin) {               \
    case 0: PORTD &= ~(1<<0); break;    \
    case 1: PORTD &= ~(1<<1); break;    \
    case 2: PORTD &= ~(1<<2); break;    \
    case 3: PORTD &= ~(1<<3); break;    \
    case 4: PORTD &= ~(1<<4); break;    \
    case 5: PORTD &= ~(1<<5); break;    \
    case 6: PORTD &= ~(1<<6); break;    \
    case 7: PORTD &= ~(1<<7); break;    \
    case 8: PORTB &= ~(1<<0); break;    \
    case 9: PORTB &= ~(1<<1); break;    \
    case 10: PORTB &= ~(1<<2); break;   \
    case 11: PORTB &= ~(1<<3); break;   \
    case 12: PORTB &= ~(1<<4); break;   \
    case 13: PORTB &= ~(1<<5); break;   \
    }
8  Using Arduino / General Electronics / Re: ATTiny85 SOIC Eagle footprint on: September 09, 2014, 10:55:03 am
Thanks guys!  I don't know any easy way to measure exact distances in Eagle so it's pretty impossible to see  sizes of existing packages. I will get Element14's library!
9  Using Arduino / Audio / Re: Real time MIDI w/ music shield on: September 09, 2014, 10:53:24 am
I haven't played with it for a long time. I think this sketch should work if you connected all the pins correctly. It will just play middle C note.
Code:
#include <SD.h>
#include <SPI.h>
#include <MusicPlayer.h>

void setup()
{
  Serial.begin(115200);
  midiInit();
 
  //player.midiWriteData(0xC0, 1, 0); // Select instrument
  middleC();
  //triggerNotes();
 // playMIDIMelody();
 
}
void loop()
{
  //player.play();
 
  //delay(500);
}

void triggerNotes() {
  for (int note = 30; note <87; note++) {
    player.midiNoteOn(0, note, 127);
    delay (50);
    player.midiNoteOff(0, note, 127);
    delay (50);
  }
 
}

// Play one note for all instruments in bank GM1
void middleC(){
  setMIDIBank (1);
  for (int i=0;i<127;i++) {
    Serial.print ("Playing instrument: ");
    Serial.println (i);
    player.midiWriteData(0xC0, i, 0); // Select instrument
    player.midiNoteOn(0, 60, 127); // Play C4
    delay (1000);
    player.midiNoteOff(0, 60, 127); // Stop playing C4
  }
}

void playMIDIMelody () {
  // Note numbers
  int C4=60,D4=62,E4=64,F4=65,G4=67,A4=69,B4=71,C5=72;
  int PP=0; //Pause
  int melody[] = {C4,C4,PP,G4,G4,PP,A4,A4,PP,G4,PP,PP,PP,PP,
                  F4,F4,PP,E4,E4,PP,D4,D4,PP,C4};
  // note durations: 4 = quarter note, 8 = eighth note, etc.:
  int noteDurations[] = { 8,8,8,8,8,4,
                        8,8,8,8,8,4,
                        8,8,8,8,8,4,
                        8,8,8,8,8,4,
                        8,8,8,8,8,4};
  player.midiWriteData(0xC0, 1, 0); // Select instrument
 
  for (int thisNote = 0; thisNote < 24; thisNote++) {
    if (melody[thisNote]==PP) // Pause
      delay (50);
   else {
      player.midiNoteOn(0, melody[thisNote], 127);
      delay (250);
      player.midiNoteOff(0, melody[thisNote], 127);
      Serial.println (melody[thisNote]);
    // to distinguish the notes, set a minimum time between them.
    // the note's duration + 30% seems to work well:
      delay (200);
    }
  }
 
 
}

// Initializes MIDI
void midiInit(){
  player.beginInMidiFmt();
  player.midiWriteData(0xB0, 0x07, 120); // Set MIDI channel volume
}

// Sets MIDI bank to GM1 or GM2. Takes values 1 or 2
void setMIDIBank(byte bank) {
 if (bank==1) player.midiWriteData(0xB0, 0, 0x00);  // Select bank GM1
 else player.midiWriteData(0xB0, 0, 0x78);  // Select bank GM2
}
10  Using Arduino / General Electronics / ATTiny85 SOIC Eagle footprint on: September 08, 2014, 11:02:55 pm
Eagle 6.x has various Atmel parts, many look like correct package, but they all different in size. Can someone tell me if there's an existing part that has same foot print as ATTiny85 SOIC version?
11  Using Arduino / Audio / Re: Real time MIDI w/ music shield on: September 08, 2014, 09:29:52 pm
Hi bratan, do you have a copy of your edited MusicPlayer.h? Can you share it with the group.
Thanks muchs
Sure here it is...
12  Using Arduino / General Electronics / Re: Ambient Light Sensor vs LDR on: September 03, 2014, 02:49:42 pm
Great, thanks for the link!
13  Using Arduino / General Electronics / Re: Ambient Light Sensor vs LDR on: September 03, 2014, 02:10:05 pm
Note: you might wish to revise your description of the circuit you posted. They don't agree.
Sorry about that, you are right, I revised it.

The circuit design will be similar to that for an LDR, but you MUST consult the data sheet, which has an example circuit and all the other information you will need to properly design the interface and interpret the results.
On DataSheet pg 6 there's a circuit, but I don't understand it. Is it internal circuit of the device?  What is Capacitor doing there?

EDIT: I think I understand more now. Device I'm talking about is Phototransistor (right?).  Application is probably the same as LDR, 10K resistor should work?  I'm building simple LED badge that will dim LED's (via AVR's PWM) when it's dark and make them brighter when it's a lot of ambient light. From what I'm reading Phototransistor sense light changes faster, but for my purpose I don't care that much. It's more important to have light sensor in SMD package, and I couldn't find any easily sourceable LDRs in SMD packages smiley
14  Using Arduino / General Electronics / Ambient Light Sensor vs LDR on: September 03, 2014, 01:39:53 pm
I'm building custom circuit that has this SMD Ambient Light Sensor: ALS-PT19-315C/L177/TR8
I never dealt with these before, but I did built stuff with LDRs.
Will circuit be same as for regular Light resistor?  Meaning AVR analog pin will read voltage from Ambient Light Sensor and will have 10K resistor between second lead of sensor and ground?
15  Using Arduino / General Electronics / Re: DS3231 purpose of 2 resistors? on: June 02, 2014, 10:44:12 am
It seems mad they no longer make the 8 pin package when all the extra 8 pins on the 16 pin package are just grounded.
Oh yeah good point, SO16 is what I can find anyway... BTW I can only find eagle library for SO16W (wide?) version. Is there much difference between SO16 and SO16W? 
Pages: [1] 2 3 ... 26