Show Posts
Pages: 1 ... 20 21 [22] 23 24
316  Using Arduino / Programming Questions / Re: LED with Music Notes on: December 27, 2012, 07:54:03 pm
John,

Thanks but to tell you the truth its all Greek to me. I am an Network guy. I deal in IP''s address and routing tables. 

I can understand some of it but not all. I am trying to find a good book that examples the Arduino Code and how to use it. But so far I have only seen books that are to Basic or way over my head.

If any one lives the West Palm Beach Fl area and would be willing  to tutor  or over the phone PM me.

Thanks

You're copping out kculm.  Try putting these lines in order:
Code:
      playNote(notes[i], beats[i] * tempo);   // 2) tell the note to play
      digitalWrite(ledPins[i], HIGH);         // 1) turn on the appropriate LED
      delay (100);                            // 4) delay 100 milliseconds
      digitalWrite(ledPins[i], LOW);          // 3) turn of the LED
317  Using Arduino / Programming Questions / Re: LED with Music Notes on: December 27, 2012, 06:37:25 pm
This is what I got, I found it online and just added the rest of the notes.

It works kind of.  It turns on one lite per beat not per not.

I may be to green to take on a task like this.  

Thanks for any help you can give.

Code:
...
    else {
      playNote(notes[i], beats[i] * tempo);
      digitalWrite(ledPins[i], HIGH);
      delay (100);
      digitalWrite(ledPins[i], LOW); 
...

Looks to me like you're pretty close.  But I think what you want to do is:
1) turn on the appropriate LED
2) tell the note to play
3) turn off the LED
4) delay 100 milliseconds

Do you see what you need to change, above?

Cheers,
John
318  Using Arduino / Programming Questions / Re: Array initialising on: December 27, 2012, 01:33:57 pm
Can you tell me the difference between constant, reference and volatile??
Quote
... References are also known as pointers; ...

That's a pretty interesting point of view.

Quote
... there are plenty of internet articles that explain them. ...

Now that part is true, google "c++ reference vs pointer".  This one looks pretty good http://www.embedded.com/electronics-blogs/programming-pointers/4023307/References-vs-Pointers

John
319  Using Arduino / Programming Questions / Re: URGENT!! Aquaponics System w/ monitoring using Time.h and BlinkWithoutDelay on: December 27, 2012, 11:43:35 am
... I pick at your code till I got the alarms working cant have alarms with same name ie has to be pumpalarm1 pumpalarm2 etc.... it in your code I edited and posted it all hope this helps you as much as it has help me been working and testing for 3 hrs enjoy
                                                                                       Thanks dyslexic

1) You don't have to have different function names in the repeatAlarm
2) By default the library allows a max of 6 repeating Alarms, see the readme.txt file in .../libraries/TimeAlarms

Good luck,
John
320  Using Arduino / Programming Questions / Re: Blink Without Delay Help on: December 26, 2012, 12:13:22 pm
i got this code
Code:
...
void loop()
{
  for (int i = 0; i<50;i++)
 {
  switch (state){
  case 1:
    digitalWrite(Led,HIGH);
    currentMillis = millis();
    state=2;
it compile but cant do anything at all

Hi Ash,

You don't need a for loop because the whole loop() function gets called over and over already by the Arduino framework.  You only need to keep track of when things need to happen, and if it's time for something to happen.  See if you can understand this version.  Good luck!

Code:
const int LED=11;
void setup(){
    pinMode(LED, OUTPUT);
}

long nextTime=0;
bool nextState=HIGH;
long count;

void loop(){
    long currentTime=millis();
    if (currentTime < nextTime) return;  // if not time for something to happen, just return

    // it's now time to make nextState happen
    if (nextState==HIGH){
        // turn it on and schedule OFF in 5 seconds
        digitalWrite(LED, HIGH);
        nextState=LOW;
        nextTime = currentTime + 5000;
    }
    else {
        // turn it off and schedule ON in the right number of seconds according to "count"
        digitalWrite(LED, LOW);
        nextState=HIGH;
        if (count < 11){ nextTime=currentTime + 5000; }
        else if (count < 21){ nextTime=currentTime + 4000; }
        else if (count < 31){ nextTime=currentTime + 3000; }
        else if (count < 41){ nextTime=currentTime + 2000; }
        else if (count < 51){ nextTime=currentTime + 1000; }
        else {
            // what should happen after it has blinked 50 times?
        }
        count = count + 1;    // or just "count++'"
    }
}

321  Using Arduino / Programming Questions / Re: Blink Without Delay Help on: December 26, 2012, 10:33:26 am
That article is confused. Once you work in unsigned's, you forget about negative.
...

Which article?
322  Using Arduino / Programming Questions / Re: Audioino? on: December 24, 2012, 02:47:14 pm
I understand how isp works. Can I not use Arduino as ISP for something like this? I have ordered a usbasp but even when I get it, dont I have to edit the boards.txt file for the bootloader to show up on the arduino IDE so i can burn the bootloader? Thats the part I am confused on.

This seems to be a pretty good link about burning bootloaders using Arduino as ISP: http://www.ladyada.net/library/arduino/arduinoisp.html.  See the very last bit about using the avrdude command line to be able to specify a different bootloader's hex file.

Let us know how you come with this, it sounds pretty interesting to me!  I wonder if you could install a wav file to such a device using an iPhone or Android...

John
323  Using Arduino / Programming Questions / Re: Meeting a variable created in setup(). on: December 20, 2012, 04:40:21 pm
Very nice, I didn't know the malloc() funtion. The only doubt is that I am only used to managing double array by rows and columns. With this code how I know how many rows and columns there are?
Does this help:
Code:
byte **variable = NULL;
int rows;
int cols;
void setup()
{
  rows = EEPROM.read(0);
  cols =  EEPROM.read(1);
  // Here I already know the sizes.
   variable = (byte **)malloc(rows * cols * sizeof(byte));
}

void loop()
{
  // "Handling variable" as you put it
   for (int r=0; r<rows; r++)
     for (int c=0; c<cols; c++) {
        variable[r][c] = 17;
     }
}

324  Development / Suggestions for the Arduino Project / Re: String corrupts the heap and crashes on: December 20, 2012, 12:24:22 pm
Ok, thanks.

I remember last year when starting with Arduinos, finding that problem and eventually your malloc.c fix in the bug report.

A few months ago I discovered Teensy and have mostly been using them since...

Cheers,
John
325  Development / Suggestions for the Arduino Project / Re: String corrupts the heap and crashes on: December 19, 2012, 10:06:44 pm
Here's the bug report:

http://code.google.com/p/arduino/issues/detail?id=857

You may want to comment there about your belief that it should be urgently fixed. Maybe it'll move to "implemented" in version 1.0.2.


Perusing this thread and the bug report linked above I note that the bug tracking shows this has now finally been "fixed".
Quote
Comment 29 by project member c.mag...@bug.st, Dec 17 (2 days ago)
Done. Thank you.
https://github.com/arduino/Arduino/commit/d457332664730fde14146649169b1fdfe2209514
Please check the fix.

How will I know when this bug fix has made it into the official downloadable version 1.x.x?

Thanks,
John

(I hate C but love C++.  Mainly e.g. because of char* vs String)


326  Using Arduino / Programming Questions / Re: Trying to turn off an output 1second after a switch is tripped on: December 19, 2012, 09:13:09 pm
Or,

  if (latch) {
  ...
  }
327  Using Arduino / Programming Questions / Re: What is this in the class on: December 19, 2012, 04:09:53 pm
Google "c++ static member".

In c++, static means there is only one of the thing for all objects of that type, and it is shared among all instances of that class.

IIRC you can access static members through instances, in your example   ds.crc8(addr, 7) as well as OneWire::crc8(addr, 7).  It would be calling the same method.  But understand that the result of the crc8() function does not depend on any data or state in any particular OneWire object instance like "ds".

HTH,
John

328  Using Arduino / Programming Questions / Re: Cosm sketch for official ethernet shield on: December 18, 2012, 05:39:17 pm
Works great for me.

John
329  Using Arduino / Programming Questions / Re: URGENT!! Aquaponics System w/ monitoring using Time.h and BlinkWithoutDelay on: December 18, 2012, 05:29:57 pm
so I attempted to re do my code to incorporate both the LightAlarm() , LightAlarmOff(), PumpAlarm(), PumpAlarmOff(). And here was my attempt.

Hi Savtitan, your code is looking better, but the things I noticed were:
1) There is a typo , at 8am you are turning on AND turning OFF
2) I have not used the TimeAlarm library but I found this statement regarding it:
    "Failing to regularly call Alarm.delay will result in the alarms not being triggered"
   So at the bottom of your loop() function you should probably add something like
   Alarm.delay(1000);

When you test your code do you have to sit around and wait for the next "turn-on" time?

John
330  Using Arduino / Programming Questions / Re: Need help with Chess Algorithm for Arduino. on: December 18, 2012, 05:02:46 pm
The original IBM PCs used 8-bit at 5-10 MHz clock speeds and could play chess. Why not a 16 MHz processor?
And prior to that 8 bit CP/M systems running Z-80 at 4 mhz had usable chess programs that could be selected to play at maybe up to six levels of difficult, and while certainly not 'master level' competent it could give a beginner and intermediate chess player a good game. I just don't know how SRAM intensive it is/was, so that might have a bearing if an arduino could do it.

 Lefty

Sargon, 1979.  It was fun.
Pages: 1 ... 20 21 [22] 23 24