Show Posts
Pages: [1] 2 3 ... 20
1  Forum 2005-2010 (read only) / Troubleshooting / Re: Pins 2 and 3 can't light up an LED? on: January 06, 2008, 04:47:43 pm
i'm sorry. then i don't know. there's no extra resistors for these pins on the board http://www.arduino.cc/en/uploads/Main/Arduino-Diecimila-schematic.pdf

what kind of led matrix did you use? did you try to connect just one LED to pin 2 (or 3 ) and GND ? same effect?
maybe the problem is not the provided current but the current sinking on the other side (GND or corresponding pin in your matrix setup). this wouldn't explain anything but help to track down the problem.

i'm sure i've used LEDs on all pins without noticing differences.

2  Forum 2005-2010 (read only) / Troubleshooting / Re: Pins 2 and 3 can't light up an LED? on: January 05, 2008, 07:21:16 am
did you declare these pins as outputs? the atmega has internal resistors.


Code:
pinMode(2,OUTPUT);
pinMode(3,OUTPUT);

kuk
3  Forum 2005-2010 (read only) / Troubleshooting / Re: piezo to midi code help wanted ! on: December 18, 2007, 10:00:46 am
use the #Button when posting code
Code:
you get this box then, which makes it easier to read formatted code


you have to close your {blocks of code} like
Code:

if (someCondition==true){              //<-start  conditinal block {
    //do something here
}                                                  //-> closing the block }


or

Code:

void loop(){                                       //<-open loop block {
    if (someCondition==true){              //<-start  conditinal block {
        //do something here
    }                                                  //-> closing the if block }
}                                                      //-> closing the loop block }


that too was part of the problem in your first example.




4  Forum 2005-2010 (read only) / Troubleshooting / Re: piezo to midi code help wanted ! on: December 18, 2007, 08:02:14 am
now it works:
Code:
int ledPin = 13   ;    // Led connected to digital pin 13
int piezo1 = 0   ;     // Piezo 1 connected to analog 0
byte val = 0     ;     // variable to store the value read from the sensor pin
int statePin = 0; // variable used to store the last LED status , to toglle the light
byte THRESHOLD = 100;  // threshold value to decide when the detected sound is a knock or not
 
void setup()  
{
 pinMode(ledPin, OUTPUT); // declare the ledPin  as OUTPUT
 Serial.begin(31250);  // set MIDI baud rate  
}  
 
void loop(){
 // deal with first piezo
  val = analogRead(piezo1)/4;  
  if (val >= THRESHOLD) {  
   noteOn (144 , 10, 100);
    digitalWrite(ledPin, HIGH);
    delay(100);
  }  
}


// plays a MIDInote doesn't check to see that cmd is greater  than 127 or that data values are less than 127
void noteOn(char cmd, char data1,char data2) {
  Serial.print(cmd, BYTE);
  Serial.print(data1, BYTE);
   Serial.print(data2, BYTE);
}

just a typo: you wrote 'data 2' instead of the variable name data2. and added a few semicolons at the bginning.

//kuk


EDIT: i probably changed more than needed to be done. don't mind this, took me some time to see the problem
5  Forum 2005-2010 (read only) / Troubleshooting / Re: how to start .... on: November 16, 2007, 08:33:57 am
do you need/want your pc in between? you could just hook a joystick (non-usb) to the second x-bee-arduino.

to get started i would suggest the following:
1- wire and get an arduino to talk to your bot, try programming some test movements like left-right, forwards-backwards.
2- if this works, try to control it with your pc: write an arduino sketch that takes commands from the serial port (via usb).
3- finally get that wireless working (if you haven't already), and throw it all together

i think there is a handful of information for the last steps here on the forum or the wiki/playground. if you built the bot, you maybe know how to interface it. there are tutorials on controlling motors and servos though as well.

good luck,
kuk
6  Forum 2005-2010 (read only) / Troubleshooting / Re: New code not running despite flawless flash on: November 01, 2007, 03:48:40 pm
Quote
 Or at least that seems to have fixed the problem for other people.
i just did a "re-burn" to a mini and an arduino NG's atmega. Same Symtoms before, everything fine afterwards.
7  Forum 2005-2010 (read only) / Troubleshooting / Re: interrupts and rotary encoders on: September 05, 2007, 06:34:03 pm
interrupts do (as their name implies) interrupt you program. that means, they might easily stop your program from running at all.
that is if you interrupt too often and your interrupt routine can't even finish before the next interrupt is triggered.

you shouldn't send serial messages from within the interrupt routine. keep it as simple as possible. keep it as fast as possible. count your values and give the control back to the main loop.

if you need to send a serial message when an interrupt occured, set a variable (interrupt_did_happen=true) and then send the message from within the main loop:

if (interrupt_did_happen ){
 //send message here
}


again, i hope this helps. if not, it might be good to post some code. or maybe try to explain what you want to do. this was just a shot in the dark (though i know what my difficulties with interrupts were).

//ku k
8  Forum 2005-2010 (read only) / Troubleshooting / Re: interrupts and rotary encoders on: September 05, 2007, 10:55:12 am
ps: by just having one channel triggering an interrupt you only get half of the resolution of your encoder. If you need the full resolution you have to use two interrupts per encoder.  
9  Forum 2005-2010 (read only) / Troubleshooting / Re: interrupts and rotary encoders on: September 05, 2007, 10:38:58 am
i'd say that he means it does not matter if you connect your encoder's pin "A" to arduino's port 3, and "B" to 4 <b>or the other way around</b>.

you're right that interrupts only work on pin 2 and 3. Paul's code only uses one interrupt on pin2, and "just reads" the value from pin4. Basically that means you could read a second rotary encody using the interrupt functionality of pin 3 plus any other digital in.

i hope this helped.

best, kuk
10  Forum 2005-2010 (read only) / Troubleshooting / Re: Timer, SSI-Interface on: May 07, 2006, 03:35:43 am
hi Stephan,

what kind of rotary encoder do you use?   i need to read the position of a hand crank.

best, kuk
(actually Stephan too smiley
11  Forum 2005-2010 (read only) / Troubleshooting / Re: strange behavior on my prog ! on: April 14, 2006, 05:59:43 pm
i can't get it work neither.

Code:
const char *sNomJour[7]   __attribute__((section(".eeprom"))) = {"dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"};
i don't think that this line writes anything to eeprom

i read out the eeprom in the main loop function afterwards but it always showed the values that i put there the run before.
Code:
      int EEadr;
      
      for ( EEadr=0;  EEadr<512;  EEadr++){

        value1 = eeprom_read_byte(EEadr);

        printInteger(EEadr);
        printByte(62); //">"
        printHex(value1);
        
        printNewline();
     // eeprom_write_byte(EEadr,0xDD); //uncommented in the second run
      }
is giving out 0xDD for all addresses.  :-/
12  Forum 2005-2010 (read only) / Troubleshooting / Re: strange behavior on my prog ! on: April 14, 2006, 11:31:13 am
hi guys,

i'm wondering if you figured this out in the meantime!?

as documented in another thread, i am interfacing a graphical LCD.
The original code (threw in by massimo) defines the ASCII characters in pixels.

like that:

Code:
static const byte FontLookup [][5] =
{
  {
    0x7E, 0x11, 0x11, 0x11, 0x7E     }
  ,   // A
  {
    0x7F, 0x49, 0x49, 0x49, 0x36     }
  ,   // B
  {
    0x3E, 0x41, 0x41, 0x41, 0x22     }
  ,   // C
  {
    0x7F, 0x41, 0x41, 0x22, 0x1C     }
     //D
//...
}
using this code the array is stored in RAM right? or is it in the flash memory??? (BTW what does the "static const" declaration do exactly?)

since every character takes 5 Bytes of memory and there are 95 printable ascii characters, i'm constantly running out of memory when working on the code. those 512 bytes of eeprom would come very handy!

is there a way to put all those pixel bytes into the eeprom using the ide? if i understand it right, the bootloader just copies the program into the flash-memory. is the bootloader able to write into eeprom at all?

i know i could copy the bytes from the RAM to the EEPROM using eeprom_write_byte(adr,val); but as it looks i'm not even able to get the program up running with *every* ascii character describe. :-(

another question:

is the eeprom used for anything when doing *normal* arduino stuff (no fancy c)? as a buffer for serial communication or something? or some debugging data maybe? just because it wasn't empty when i first accessed it for testing.


hope to hear from you.
i whish you all a nice easter weekend.

kuk

13  Forum 2005-2010 (read only) / Troubleshooting / Re: real string functions? on: April 24, 2006, 11:06:45 am
hi gck,

your last point is a good one. How do i know if my sketch is linking to an external library? the IDE does this linnking automatically, when i'm making use of "string functions" for example, right?

i thought that string.h was linked to anyway, like a kind of standard library. thats not right i guess.

and is there a way to tell how big those different libraries are? what libraries exist at all at the moment for arduino?

hey, and best wishes to massimo!

kuk
14  Forum 2005-2010 (read only) / Troubleshooting / Re: real string functions? on: April 23, 2006, 05:40:21 am
you're totally right.

sorry for upsetting you. the examples were just chosen to simplify the problem.

of course i won't send "arduino, please turn all lights off exept no. 12". what i was trying to do is letting arduino understand and handle ESC sequences. a maximum of 3 characters at the moment.

after all, understanding (i'm not there yet) strings and pointers, seemed a good start for understanding why my programs keep crashing :-)
it works now.

the problem was that i  tried to reset the string with: myString="";

or even:  myString="\0";  // for zero termination

both didn't work.

strcpy(myString, "");

did the trick.
thank you, kuk






15  Forum 2005-2010 (read only) / Troubleshooting / Re: real string functions? on: April 21, 2006, 01:24:26 pm
hmm, can i add a single char to an existing string?

like

char *mystr = "hello worl";
char singleChar = "d";

*mystr = strcat(*mystr , ch):

printString(*mystr);

or similar?
Pages: [1] 2 3 ... 20