Show Posts
Pages: 1 ... 6 7 [8] 9 10 ... 294
106  Using Arduino / Programming Questions / Re: Problems with is statement on: September 12, 2014, 10:55:12 am
Here is the code
Wrong.  That is only some of the code. 
Please post it all.
107  Using Arduino / Programming Questions / Re: Code review request for RC car on: September 12, 2014, 04:41:12 am
You have not said what is wrong but from
on boards other than the Mega, use of the library disables analogWrite() (PWM) functionality on pins 9 and 10, whether or not there is a Servo on those pins.
and in your program you have
#define MOTOR2_PWM   10 // EB  
analogWrite(MOTOR2_PWM, motor_speed);  

Try moving the affected PWM output to another pin.
108  Using Arduino / Programming Questions / Re: More qusetions about "functions" and how they work. on: September 12, 2014, 02:40:27 am
I think you are making more complicated that it is.
To set LED to red you code sends RGB = (255,0,0) , to set  blue you send RGB (0,0,255).
Now if you set SAME LED using BOTH codes it will PHYSICALLY mix the colors.
The software does not care if you send TWO lines of code to sane LED "output"
or ONE line of code
Color(255,0,255);  to same LED
Is sending 255, 0, 0 then 0, 0, 255 really the same as sending 255, 0, 255 ?

Surely sending 255, 0, 0 then 0, 0, 255 will leave the LED blue
109  Community / Bar Sport / Re: [RPI ?] Wiringpi, Bash, and PWM on: September 11, 2014, 02:39:14 am
Sorry. I didn't know there were multiple ways to connect a transistor
Not only that, there are multiple types of transistor.
The transistor is between the negative lead of the fan.
Between the negative lead of the fan and where ?
The center pin of the transistor is  connect to pin 18 of the pi
That pin does what exactly on the Pi ?
There is a capacitor between the fans + & - lead,
What type/value of capacitor ?
to have enough power to kick on and not draw to much from the device.
This is surely nonsense.
The fan won't kick on with 3.3v. Which is the rating I get with my multimeter from the PWM signal set at 1023. It will with direct 5v.
Do you understand that a PWM output does not provide a steady voltage ?  Rather it provides a fixed voltage that turns on and off, ie is Modulated, with a variable duty cycle depending on the Width of the Pulse
110  Using Arduino / Programming Questions / Re: Help with initial project on: September 10, 2014, 06:37:19 am
The problem is that the program runs non-stop and doesn’t do what I want
What does it do ?
How are the buttons wired Have you got any pull down resistors on the inputs to ensure that they are held at a known voltage when not pressed ?  If not, I suggest that you use
pinMode(buttonPin2, INPUT_PULLUP);
to activate the built in pullup resistors and change the wiring to take the inputs LOW when activated,  then use
if (buttonState2 == LOW)
to check the state of the input.  LOOK CAREFULLY at the code I used in the if.  Does it differ from yours besides the test being for LOW instead of HIGH ?
111  Using Arduino / Programming Questions / Re: Mosquito Anti Loitering Device on: September 10, 2014, 06:08:24 am
      if (pirState == LOW)//we have just turned on
Actually what you know is that the sensor was active when you checked 30 seconds ago.  Was it active for a fraction of a second ?  Is it still active ?  Who knows ?
112  Using Arduino / Programming Questions / Re: Counting and loop question on: September 10, 2014, 05:01:27 am
What benefits do i gain from increasing the baud rate from 9600 to 115200?
As BL says, none in this sketch but it is the rate at which I usually set it.  The important thing is that the baud rate in the program matches that of the serial device being communicated with.  As there is no serial communication in this program the Serial.begin() is not even needed but I tend to put it in because of the inevitable need to print for debugging.  I did not include it in the code posted but I originally had
Serial.println(255 - count);
in the lightLeds() function which allowed me to see the values without the need to wire up the LEDs.
113  Using Arduino / Programming Questions / Re: Counting and loop question on: September 10, 2014, 01:49:15 am
255 - count will give you the inverse of the value of count.

The code can be tidied up quite a lot.
const byte led1 = 9;
const byte led2 = 10;

void setup()
  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);

void loop()
  for(int count = 0; count <= 255; count++)

  for(int count = 255; count >= 0; count--)

void lightLeds(int count)
  analogWrite(led1, count);
  analogWrite(led2, 255 - count);
3 parameters in each for loop
Cretae a function for code used more than once
count variable declared locally to where it are needed in the for loops
const byte used for LED pin numbers
Each brace on its own line to aid readability
114  Using Arduino / Programming Questions / Re: Momentary output signal on: September 09, 2014, 11:45:29 am
are not consistent.
But, annoyingly enough, not wrong.
That's why I chose my words carefully.
115  Using Arduino / Programming Questions / Re: Momentary output signal on: September 09, 2014, 02:46:32 am
Robin - I appreciate that your code was incomplete and untested but
boolean relayState = false;
relayState = 'S';
are not consistent.

116  Using Arduino / Programming Questions / Re: will this work? on: September 09, 2014, 01:34:51 am
i'm trying to use this for save space in code.
I presume that you are asking if the program will work with the code spread over several lines.  So create a small example and try it.  Put the code in setup so that it only runs once and print the result to see whether it works.  Do this before you potentially waste your time typing in possibly hundreds of lines of code.

As Robin has hinted, multiple ifs may not be the best way to do this but as you have not shared your whole program we cannot offer other solutions.
117  Using Arduino / Programming Questions / Re: Problem Inserting Small Sketch into Large Sketch on: September 09, 2014, 01:28:06 am
As a first step in debugging the problem by Auto Formatting your code.  It will report that you have too many right curly braces.

Now to track down what is wrong.  Place the cursor to the right of an opening brace and the IDE will indicate the matching brace by placing a box round it.  Check each pair of braces, such as those starting and ending functions, loops, if blocks etc until you find the problem.  Start with the opening brace of the loop() function.  The IDE matches it to the line
  }//end of music

You may find that the structure of the program is easier to see if each opening and closing brace is placed on its own line.  The structure is even easier to see when the code is indented consistently.
118  Using Arduino / Programming Questions / Re: Need help with Rover 5 Robot on: September 08, 2014, 11:29:30 am
119  Using Arduino / Programming Questions / Re: Time and TimeAlarms Libraries – Ask here for help or suggestions on: September 06, 2014, 12:03:22 pm
Serial.write(MESSAGE,BYTE) and this don't work on Arduino 1.0. ...
That is not a bug.  it is a deliberate, documented change introduced with release 1.0
120  Using Arduino / Programming Questions / Re: error in displaying file names from sd card on: September 06, 2014, 02:36:34 am
i cant understand where i made mistakes.
Nor can we because you did not post your program so that we could see we could see what you are doing.
Pages: 1 ... 6 7 [8] 9 10 ... 294