Show Posts
Pages: 1 ... 16 17 [18] 19 20 ... 285
256  Using Arduino / Programming Questions / Re: Self Balancing sketch runs only when usb is connected on: July 19, 2014, 07:31:37 am
Wow, the soldering on those motor connections is awful !
257  Using Arduino / Programming Questions / Re: cozir library not finding .h file on: July 19, 2014, 05:07:34 am
I have installed the cozir library 1.0.3 for the cozir co2 module in Arduino 1.0.5 on ubuntu.
Where exactly is the file installed ?
#include "cozir.h"
the header file should be in the same directory as you program.
Compare that with
#include <SoftwareSerial.h>
which indicates that the header file is in the libraries folder.
258  Using Arduino / Programming Questions / Re: Run loop one time? on: July 19, 2014, 01:44:12 am
would that mean I should just move where I have the notes being played? Or would I need some IF THEN statements?
You need some logic to detect that the PIR state has changed and that it is now HIGH and was previously LOW
currentVal = digitalRead(IRpin);
if (currentVal == HIGH  && previousVal == LOW)
  // the PIR has been triggered so do something
previousVal = currentVal;
259  Using Arduino / Programming Questions / Re: MATHS PROBLEM!!! on: July 18, 2014, 05:37:16 am
As you can see Irms is a value I read off from a device
Actually I can't see that.  Please post your whole program.
260  Using Arduino / Programming Questions / Re: Servo Code Double Check on: July 18, 2014, 02:36:20 am
Judging by the voltages that you mentioned the servo is being supplied 5V from the Arduino.  If so that is not a good idea because the servo can easily take more current than the Arduino voltage regulator can supply.  Consider powering the servo from an external supply but don't forget to connect the two grounds.
261  Using Arduino / Programming Questions / Re: Run loop one time? on: July 18, 2014, 01:43:10 am
Look at the state change detection example in the IDE.  You need to trigger the sound when the PIR becomes LOW, not when it is LOW.  All this involves is checking its current state against it previous state and acting if it has changed and is now LOW when previously it was HIGH.
262  Using Arduino / Programming Questions / Re: Void Setup on: July 17, 2014, 07:18:07 am
A function can have almost any name as long as it does not contain spaces or punctuation.

It is good practice to give functions meaningful names that indicate what they do and the use of 'camelCase' for names is common.  So you will see functions such as digitalWrite(), pinMode() etc built into the Arduino environment and you can write your own to do common tasks and/or make program maintenance easier. 

The myFunction() used in previous replies was only an example.  It could just have well been called wibble() for all the IDE cared !
263  Using Arduino / Programming Questions / Re: PWM Pins 9 and 10 on Uno on: July 17, 2014, 07:09:32 am
In your program you attach the servo only in setup(), which is the correct place but that means that you cannot use pins 9 and 10 for PWM output as I suspected..  Did you choose which pins to use for which purpose or are you using a motor shield which requires certain pins to be used ?

It may still be possible to use pins 9 and 10 but that would require the servo object to be detached before using them and attached again afterwards which sounds very messy.  You could do yourself a favour and put the analogWrite() commands in a function along with the servo detach and subsequent servo attach then call the function when required.

On the whole, using other pins would be the best solution although there is an alternative servo library (ServoTimer2) that allows PWM on pins 9 and 10
264  Using Arduino / Programming Questions / Re: Switch Control on: July 17, 2014, 12:52:27 am
if the while loop condition is not fulfilled, it will read the switch value again and again till it is satisfied.
That's better.  Now the while loop can end, whereas before it never, could so the program would stall.
265  Using Arduino / Programming Questions / Re: Game of Life generation not being pushed to 16x32 LED matrix on: July 16, 2014, 03:09:48 pm
An array of booleans usea half as much memory as an integer array.

As a test as to whether memory is the problem, how about reducing the size of the array to say 8 by 8 initially ?
266  Using Arduino / Programming Questions / Re: Void Setup on: July 16, 2014, 07:23:28 am
Try this
void setup()
  int theAnswer = multiplyFunction(4, 5);
  Serial.println(multiplyFunction(11, 555));

void loop()

int multiplyFunction(int x,int y) {    // x & y are declared as integers.
  int result = x * y;
  return result;                    //returns the value where it is called
The value in the result variable in the function is returned (made available) to the code that called the function.  It does not have to be put into a variable but can be used directly as in the second example above.

setup() and loop() don't, in normal use, have a program calling, them so cannot return a value, hence their return type is void.
267  Using Arduino / Programming Questions / Re: Strange Interrupt Behaviour on attach on: July 16, 2014, 07:11:53 am
attachInterrupt(1, vibration1, FALLING); //doesn't work. Triggers interrupt routine instead.
This is a strange comment. I always thought the purpose of attachInterrupt was to trigger an interrupt routine.
Surely the act of attaching the interrupt should not actually trigger it though, merely make it possible to trigger the interrupt when the interrupt pin state changes.
268  Using Arduino / Programming Questions / Re: #define, int or const int on: July 16, 2014, 04:47:07 am
Note that
#define ledPin = 13
is not correct.  Unless, that is, you really want the pre-processor to replace all instances of ledPin with = 13, which is unlikely
269  Using Arduino / Programming Questions / Re: Game of Life generation not being pushed to 16x32 LED matrix on: July 16, 2014, 03:01:14 am
Which Arduino are you using ?

I have not looked at your code in detail but you have 2 arrays of booleans, each 18 by 34.  That is going to take over 1200 bytes so you may have a problem with lack of memory.

It would be much more efficient in terms of space to pack the data into bits rather than bytes.
270  Using Arduino / Programming Questions / Re: Programme stuck in setup on: July 15, 2014, 12:36:08 pm
Define what you mean by more powerful

More memory ?
Faster processor ?
More pins ?
More than one hardware serial port ?
etc, etc
Pages: 1 ... 16 17 [18] 19 20 ... 285