Show Posts
Pages: 1 2 [3] 4 5 ... 600
31  Using Arduino / LEDs and Multiplexing / Re: Led alternating Dimming with instant button interrupt on: September 17, 2014, 08:03:25 am
Since your delays are short you will get a button response within 5 milliseconds.

Code:
const int led = 9;
const int led2 = 10;
const int buttonPin = 4;

void setup(){
  pinMode(led, OUTPUT);
  pinMode(led2, OUTPUT);
  pinMode(buttonPin, INPUT_PULLUP);  // Active LOW
}

void loop() {
  static boolean buttonPressed = false;
  while (!buttonPressed) {
    for(int verdi = 0; verdi <= 255; verdi = verdi ++){
      analogWrite(led, verdi);
      analogWrite(led2, 255 - verdi);
      if (!digitalRead(buttonPin)) {
        buttonPressed = true;
        break;
      }
      delay(5);
    }
    for(int verdi = 255; verdi >= 0; verdi = verdi --){
      analogWrite(led, verdi);
      analogWrite(led2, 255 - verdi);
      if (!digitalRead(buttonPin)) {
        buttonPressed = true;
        break;
      }
      delay(5);
    } 
  }
}
32  Development / Other Software Development / Re: setting programming voltage on stk500 on: September 17, 2014, 07:53:38 am
The target voltage of the STK500 can be set in AVR Studio but not in the Arduino IDE.  Is your processor in a socket so it can be removed and programmed at 5V away from the 3.3V peripherals?

I think the USBasp programmer (under $4 on eBay) can be switched to 3.3V.
33  Topics / Robotics / Re: Problems to compile NewPing code for multi sensors ranging application on: September 17, 2014, 07:43:08 am
Newping_Code_for_Multiple_Sensors:16: error: 'NewPing' does not name a type

The "does not name a type" message almost always means you didn't install the matching library correctly.  Try again.
34  Using Arduino / Audio / Re: Using more than 16 analog inputs for a MIDI controller on: September 17, 2014, 07:38:27 am
Which potenciometer should I use for arduino projects? Logarithmic or linear? And which resistence? 10k... 50k? Please give me some tip about it.

Use linear if you are controlling pitch and use logarithmic if you are controlling volume?

You should use a pot less than 100k because that is the recommended limit for input impedance on the Arduino analog inputs.  If you go down to 1k they will draw 5mA each at 5V (120 mA total).  I would use 10k as a good compromise between current draw and input impedance.
35  Development / Suggestions for the Arduino Project / Re: printf - bug (missing output device?) or "feature" to promote String class? on: September 17, 2014, 07:31:55 am
http://www.nongnu.org/avr-libc/user-manual/group__avr__stdio.html

"Due to the nature of the underlying hardware, only a limited subset of standard IO is implemented. There is no actual file implementation available, so only device IO can be performed. Since there's no operating system, the application needs to provide enough details about their devices in order to make them usable by the standard IO facilities."

"No assignments to the standard streams will be performed by fdev_setup_stream(). If standard streams are to be used, these need to be assigned by the user."
36  Using Arduino / Programming Questions / Re: can I call one function from within another? on: September 16, 2014, 06:04:32 pm
do you agree that my problem is due to the variable 'a' being assign within the function and it is not recognised outside the function?

That is the main problem.  

If you want to pass the data as an array:
Code:
void writeArduinoOnMatrix4() {
 // here is the data for the characters
  // Note the use of the 'static' keyword so the array doesn't have to be re-created each time the function is called.
  static byte a[8]={B00011000,B00111000,B00111000,B00011000,B00011000,B00011000,B00111100,B00111100,};
  diplayThem(a);
}
void diplayThem(byte a[]) {
  lc.setRow(0,0,a[0]);  lc.setRow(0,1,a[1]);  lc.setRow(0,2,a[2]);  lc.setRow(0,3,a[3]);
  lc.setRow(0,4,a[4]);  lc.setRow(0,5,a[5]);  lc.setRow(0,6,a[6]);  lc.setRow(0,7,a[7]);
}

If lc.setRow() is declared with the third argument being a constant you can make the code a little safer with:
Code:
void writeArduinoOnMatrix4() {
 // here is the data for the characters
  // Note the use of the 'static' keyword so the array doesn't have to be re-created each time the function is called.
  // Note the use of the 'const' keyword to make sure the contents of the array can't easily be changed
  static const byte a[8]={B00011000,B00111000,B00111000,B00011000,B00011000,B00011000,B00111100,B00111100,};
  diplayThem(a);
}
void diplayThem(const byte a[]) {
  lc.setRow(0,0,a[0]);  lc.setRow(0,1,a[1]);  lc.setRow(0,2,a[2]);  lc.setRow(0,3,a[3]);
  lc.setRow(0,4,a[4]);  lc.setRow(0,5,a[5]);  lc.setRow(0,6,a[6]);  lc.setRow(0,7,a[7]);
}
37  Using Arduino / Programming Questions / Re: can I call one function from within another? on: September 16, 2014, 05:56:54 pm
Yes, you can call one function from another.  To pass data to a function you generally pass arguments.  I'd do something like this:

Code:
void writeArduinoOnMatrix4() {
  diplayThem(B00011000,B00111000,B00111000,B00011000,B00011000,B00011000,B00111100,B00111100);
}
void diplayThem(byte r0, byte r1, byte r2, byte r3, byte r4, byte r5, byte r6, byte r7){
  lc.setRow(0,0,r0);  lc.setRow(0,1,r1);  lc.setRow(0,2,r2);  lc.setRow(0,3,r3);
  lc.setRow(0,4,r4);  lc.setRow(0,5,r5);  lc.setRow(0,6,r6);  lc.setRow(0,7,r7);
}
38  Using Arduino / Audio / Re: Using more than 16 analog inputs for a MIDI controller on: September 16, 2014, 05:50:01 pm
With that mux shield II I can build the project with an arduino uno, right?

If you want to produce MIDI output you will need some additional hardware.  The Mux Shield II will definitely take care of the reading of 24 analog inputs which can be your 24 pots.
39  Using Arduino / Motors, Mechanics, and Power / Re: how to use the MG995 360dgrs ? on: September 16, 2014, 11:16:25 am
What you have bought is a servo modified for "continuous rotation".   It is no longer a servo that can be directed to a particular position: it is a gear-motor with a speed control.  Send it a pulse near 1500 microseconds to stop.  Lower values (down to about 1000 uS) turn one way and higher values (up to about 2000 uS) turn the other way.

If you want a servo that you can point in any direction you probably want a multi-turn sail winch servo like this 4-turn model:
http://www.hobbyking.com/hobbyking/store/__20854__sw4805_4pa_sailwinch_servo_6_13kg_45g_0_70.html
40  Using Arduino / Audio / Re: Using more than 16 analog inputs for a MIDI controller on: September 16, 2014, 11:05:35 am
Analog multiplexers will let you connect 8 or 16 analog inputs to EACH analog input of the Arduino.  You can buy a Mux Shield II which allows 48 analog inputs:

https://www.sparkfun.com/products/11723
41  Development / Other Hardware Development / Re: where i can buy a stepper motor gear like this on: September 16, 2014, 10:58:32 am
A blurry picture of one side of a gear is not sufficient.  You need to determine the specifications of the gear:  tooth count, pitch, pitch angle, width (total and just the geared part)...  Take the gear to a gear distributor and ask them for a matching gear.
42  Using Arduino / Programming Questions / Re: Mapping analog inputs - not working as expected on: September 16, 2014, 09:48:44 am
If you want the LED to stay on some you should not dim all the way to 255.  I think that instead of the range 255-50 (off to fairly bright) you intended the range 205-0 (dim to full bright).
43  Using Arduino / Project Guidance / Re: Controlling car fuel gauge on: September 15, 2014, 03:32:07 pm
Another way to determine what the gage is actually measuring is to put the gage in series with a 30-Ohm resistor and measure the current through the pair.  That should tell you the internal resistance of the gage. 

An NPN transistor driven by PWM ought to let you adjust the average current through the gage to let you display values.
44  Using Arduino / General Electronics / Re: Storing Arduino and other hardware on: September 15, 2014, 03:18:11 pm
I like the Plano Molding model 3750 "StowAway Utility Box" for Arduino stuff:

http://www.planomolding.com/product.php?BCCID=136&PID=953

I got mine in the Crafts section of Walmart.  I think Walmart sells them under the brand "Creative Options" but I can't find the exact match at the Walmart website.  If I recall correctly they were only about $6.
45  Topics / Robotics / Re: Connecting Arduino to Servos and Rotary Switch on: September 15, 2014, 11:33:09 am
The "rotery" switch isn't a rotary switch.  It's a microswitch like those used as limit switches in mechanical equipment.  It looks like there is one on each of the front corners to detect wall collisions.
Pages: 1 2 [3] 4 5 ... 600