Show Posts
Pages: [1] 2 3 ... 233
1  Using Arduino / Programming Questions / Re: How to fix this servo code on: Today at 04:44:29 pm
Reading your code is hard work because of all the blank lines so I gave up after a while, but I did notice this line
Code:
analogWrite(ledPin, 1000);
What is the maximum value that can usefully be used with analogWrite() ?

From the reference page
Quote
Syntax

analogWrite(pin, value)
Parameters

pin: the pin to write to.
value: the duty cycle: between 0 (always off) and 255 (always on).
2  Using Arduino / Programming Questions / Re: Set LED Brightness as a subroutine on: Today at 04:32:56 pm
Quote
I did not see any changes, but I figured that I was missing some syntax or something….
What AWOL was referring to was the way that the code was displayed here on the forum.  Do you see how his post displays it differently and better than yours because he used code tags ?
3  Using Arduino / Programming Questions / Re: How to fix this servo code on: Today at 04:27:56 pm
Every opening brace needs a corresponding closing brace.  Your loop() function starts with an opening brace but where does it end ?  Position the cursor after any brace or bracket and the corresponding matching one will be indicated if it is present.

If you got rid of most of the blank lines in your program it would help as would Auto formatting it (if it worked - try it and see)
4  Using Arduino / Programming Questions / Re: LED fading with for loop on: Today at 01:32:50 pm
Quote
around 75-76 mA current flowing on it
In which case this page may be of interest http://playground.arduino.cc/Main/ArduinoPinCurrentLimitations
Particularly this part
Quote
Absolute Maximum Ratings

DC Current per I/O Pin ........... 40.0 mA
5  Using Arduino / Programming Questions / Re: Need some help with my code ,please on: Today at 12:49:53 pm
Look carefully at the code as posted above and compare it with the code in the IDE.  Do you notice any italics or smileys in the IDE ?

Now edit your post to add code tags as requested in the 2 sticky threads above.  This will prevent the code being mangled by the forum software.
6  Using Arduino / Programming Questions / Re: LED fading with for loop on: Today at 12:46:19 pm
Quote
so then i decided the measure the voltage of my resistor (no led connected, only resistor and pwm is still 255)
What value is the resistor and how much current is flowing through it ?
7  Using Arduino / Programming Questions / Re: LED fading with for loop on: Today at 11:30:57 am
Quote
So I have to write Analogwrite and delay function for each "for loop".
The way it is written at the moment, yes, otherwise the LED output will never change.

How are you measuring the voltages that you refer to ?  The PWM output goes from approximately 0V to 5V and back continuously.  It is the amount of on time in each on/off cycle that causes the output to simulate a varying voltage.  If you are not measuring the voltage with an instrument that can keep up with and display the on/off signal, then what you will see is an apparently varying voltage.  Looking at the PWM output with a 'scope would be instructive.
8  Using Arduino / Programming Questions / Re: Code for Push button key pad not working as expected on: Today at 11:22:05 am
What should this code do in your code ?
Code:
10^i
What does it actually do in your code ?

This page may be instructive http://arduino.cc/en/Reference/BitwiseAnd
9  Using Arduino / Programming Questions / Re: sprintf format specifiers on: Today at 11:14:24 am
Charles Bell is correct.  Floating point output from sprintf() is not implemented by the Arduino IDE environment.  This was apparently done to save program space.

You may find this thread and the pages it links to helpful http://forum.arduino.cc/index.php?topic=125946.0
10  Using Arduino / Programming Questions / Re: Expected Initializer before 'int' Error on: Today at 11:06:28 am
Quote
Yeah, that's what I meant
I know you did, hence my jocular reply !
To make it clear to anyone reading this that does not understand what we are talking about, it should be a semi-colon.
11  Using Arduino / Programming Questions / Re: Expected Initializer before 'int' Error on: Today at 11:01:03 am
Quote
Shouldn't there be a colon at the end of the digitalWrite statement ?
No, only half of one  smiley
12  Using Arduino / Programming Questions / Re: Figure out an if else on: Today at 10:58:06 am
In the example code these 2 lines and the readQD() function put a value in the QRE_Value variable and print it.
Code:
  int QRE_Value = readQD();
  Serial.println(QRE_Value);
It is the QRE_Value variable that you need to test the value of to determine whether something was detected or not.  Try printing it as in the example code to see what values you are actually getting and when.
13  Using Arduino / Programming Questions / Re: LED fading with for loop on: Today at 10:50:26 am
Quote
I wrote
Code:
for(a=0;a<=255;a=a+10)
for(a=255;a>=0;a=a-10)
Right idea, but you are not setting the brightness of the LED anywhere
Code:
void loop() 
{
  for(a = 255; a >= 0; a = a - 10)
  {
     // set the brightness of pin 9:
     analogWrite(9, a);   
    // wait for 30 milliseconds to see the dimming effect   
    delay(30);                           
  }
//put a second for loop, analogWrite() and delay() here to fade from 0 to 255
}
14  Using Arduino / Programming Questions / Re: My first program. on: Today at 07:50:49 am
You presumably had something in mind when using
Code:
void loop(13)
What was it ?
15  Using Arduino / Programming Questions / Re: if else or switch case? on: Today at 02:23:57 am
Quote
i have about 25 if else statements, i was wondering if there would be any advantage of using switch case statements
Personally I find switch/case much easier to read and maintain, particularly if you use suitably named constants for the cases, but it is up to you.

I would hope that the compiler turns out similar efficient code for both if/else and switch/case.  You don't say what your application is doing but does absolute speed matter ?
Pages: [1] 2 3 ... 233