Show Posts
Pages: [1] 2 3
1  Using Arduino / Programming Questions / Re: Filtering twitter search results. on: September 09, 2014, 04:52:53 pm
That makes sense. Little XPath fail on my part.
2  Using Arduino / Programming Questions / Re: Filtering twitter search results. on: September 07, 2014, 12:38:27 pm
Looking at the difference between the example responses in the docs for statuses/user_timeline and search/tweets , it looks like your filters in the second case need to be /statuses/[1]/text and /statuses/[1]/user/screen_name, instead of just /[1]/text and /[1]/user/screen_name like they are for timeline.
3  Products / Arduino Due / Re: Problems programming the Due on: August 01, 2014, 03:03:01 am
I'm successfully building on Linux using a different method than yours, and I think it's simpler.

1. Download and unpack the Arduino IDE (latest 1.5 beta). Technically you only need the hardware/tools and hardware/arduino/sam directories from it; the rest isn't used and you don't ever have to run the IDE.
2. Put the Makefile from in your project directory.
3. Replace "g++_arm_none_eabi" in the Makefile with "gcc-arm-none-eabi-4.8.3-2014q1" (occurs in 4 places).
4. Set ADIR in the Makefile to the location where you unpacked the Arduino IDE, and PORT to the Arduino port (you don't need to do anything with udev, you can probably just set it to /dev/ttyACM0).

Build with "make compile", upload with "make upload". If you delete the "default:" rule, you can also build with just plain "make" like a normal project.
4  Products / Arduino Due / Re: What are the possible PWM frequencies? And how to set them. on: August 01, 2014, 02:52:09 am
Nearly any frequency from microhertz (one cycle per 3 days, or so) to 42 MHz is possible, with millions of options in between, so there's no point in printing a table. Figure out what you want, and then figure out how best to do it smiley
5  Using Arduino / Programming Questions / Re: problem with receiving variables after parsing on: September 08, 2011, 01:27:05 am
  gpsdatin=*ptr; // ptr points to $
You are assigning the address of the pointer to gpsdatin, not the contents pointed to. Get rid of the *.

This is nonsense. ptr is the address, *ptr is the char pointed to. Removing the * is an error of the hopefully-doesn't-compile variety.
6  Using Arduino / Programming Questions / Re: how to define 3 Inputs for switch/case on: May 18, 2011, 01:08:17 pm
Not that there's any need for a switch here... addition would do the job just as well.
7  Using Arduino / Project Guidance / Re: millis() overflow when? (UNO+22) on: March 19, 2011, 09:32:45 pm
Brain fart. Actually had meant to say "10 minutes a week" (around a 1000ppm error, although most seem to be within a few hundred) vs. the previous post's "10 minutes a day", but lost the thought before I posted smiley
8  Using Arduino / Project Guidance / Re: millis() overflow when? (UNO+22) on: March 18, 2011, 10:53:22 pm
Well, there's no calibration done for millis() -- it assumes that the CPU frequency is its nominal value. And the crystals on the Arduino boards aren't very good ones. But no, they're not that bad. A lousy one might be out by as much as 1 second per week.
9  Using Arduino / Installation & Troubleshooting / Re: Tried 5+ times to update Atmega8U2 on SMD Uno with no luck on: March 13, 2011, 05:48:25 pm
Sounds like you programmed the 8U2 just fine (and yes, it's reasonable for it to program very quickly) -- but that doesn't fix the bootloader bug at all, which is a completely unrelated issue.
10  Using Arduino / Programming Questions / Re: Tasks with no delay on: March 12, 2011, 12:58:38 pm
KirAsh4, in the code sample in your first post, you have a variable buttonCounter and a function that uses switch/case on that variable to set a different delay before changing the LEDs, and when the timeout expires, buttonCounter advances from 1, 2, 3, 4, back to 1, 2, 3, etc. This is very good, a basic example of a finite state machine that advances to a new state every time the button is pressed. Now, imagine a few changes to your code.

Change #1: Rename the "buttonCounter" variable to "state" or "animationState" or something -- pretty soon it won't only be counting button presses.

Change #2: Right now your switch/case is running every single time blinkLeds is called. Right now that's a harmless waste, but after Change #3 and Change #4 it will be a real problem. Move the entire switch block inside of the if (millis() - pause > prevMillis) if block. That will make it so that after running through the switch block, it won't run again until after the next delay finishes.

Change #3: Move the code that does "digitalWrite(blinker, digitalRead(blinker) == HIGH ? LOW : HIGH)" into each state -- or move it into a function and then call that function from each state. This seems like you're repeating yourself, but later on you'll make it so that each state isn't just blinking a single LED -- instead, each state will set a pattern of LEDs according to whatever animation you design.

Change #4: Make it so that a button press isn't the only thing that changes the state variable -- at the end of each state, right before the "break;", each state can set a new next state.

If you don't add any next-state assignments right away in Change #4, you should have code that still acts just like your original sample, even though it will be in a very different shape. But now there's something new you can do: have more states than button presses. For example, maybe State 1 goes to State 2 goes to State 3 which goes back to State 1, and they turn on three LEDs in a cycle. But when you press the button it will jump to State 4, which goes to State 5, which goes back to State 4. And when you press the button again it will go to State 6, which does something different. So each "pattern" can be multiple states that will keep repeating until you press the button and jump into a different pattern.

By adding logic inside of the states you can also make them more complicated -- you don't need to have one state for every combination of LEDs you want to light up. For example you could have a row of 8 LEDs with the lit LED "bouncing" back and forth with only two states. State 1 would do

case 1: /* Move right */
    Turn off LED n;
    n = n + 1;
    Turn on LED n;
    if (n == 8) {
      state = 2; /* Start moving left instead */
    } /* Else keep moving right */
    pause = 250; /* Or whatever */

And state 2 would do

case 2:
    Turn off LED n;
    n = n - 1;
    Turn on LED n;
    if (n == 1) {
        state = 1; /* Start moving right */
    } /* Else keep moving left */
    pause = 250; /* Or whatever, again */

So instead of the states being 1, 2, 1, 2, 1, 2, 1, 2, they'd be 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, ... 1 every time it moves right, and 2 every time it moves left. And the logic inside of the states changes between 1 and 2 when it's needed, saving you a bunch of code.
11  Using Arduino / Programming Questions / Re: Understanding this line " ? HIGH : LOW; " on: March 12, 2011, 12:25:04 pm
So, what is the difference between something being a method or just a function? Is it a method BECAUSE it is a function that is part of a class? Or are there other reasons? Would a C++ guide perhaps spell this part out?

In the general world of programming (not C++ specific), yes, a "method" is a function that is part of a class, and we can more specifically speak of "instance methods" (methods that are called on objects, i.e. instances of some class) and "class methods" (methods that are called on the class itself, without reference to any specific object). C++ also calls methods "member functions" (or to be painfully accurate "virtual member functions") and class methods "static member functions" for reasons that are historical and painfully silly. Java and C# also abuse the word "static" in this way. You should know the terms that your language uses, and use them when you need to be specific about things that are specific to your language, but in general you should be comfortable with the general terms. smiley
12  Using Arduino / Project Guidance / Re: built in serial to midi? on: March 11, 2011, 08:18:23 pm

This works, I have made MIDI controllers with it and its fine. the issue is that you get non usb based MIDI so u need a MIDI in for the computer.

Eek. That may work because of tolerant hardware, but it's definitely wrong. The MIDI interface is a current-loop one and that tutorial is voltage-driving it. On the transmit side the worst that's likely to cause is that it just plain won't work, but if the device on the other end tries to send a response back and it has a particularly strong driver, and the arduino's resistance is too high, it could fry the arduino handily.
13  Using Arduino / Programming Questions / Re: How do I stop and exit out of a 'for loop' on: March 10, 2011, 09:04:40 pm
"counter = 5001" is silly. If you want to break out of the loop, use break. You should say what you mean, not any random thing that happens to work. smiley
14  Using Arduino / Programming Questions / Re: while(1){} - whaaaaaaat??? on: March 10, 2011, 09:02:27 pm
On a semi-related note, does anyone know if there's any reason why the Arduino IDE prevents loop() from being declared inline? Done right, it should save several microseconds per loop (function call overhead, and stack-manip overhead if loop uses no non-static vars), which could make a real difference on tight loops. As it is, people who want this have to write their own while(1) loop inside of loop().
15  Using Arduino / Programming Questions / Re: Understanding this line " ? HIGH : LOW; " on: March 10, 2011, 12:58:47 pm
Read it and find out. You have the book with the code in it, so you know more than we do. By the looks of it, it seems like it's meant to return true when the button state has changed, but without seeing the definition, I can only guess. You have a book with the definition in it, and probably a discussion in plain english of what it does, so you unlike me, you shouldn't need to guess.
Pages: [1] 2 3