Show Posts
Pages: [1] 2 3 ... 288
1  Using Arduino / Programming Questions / Re: how do I get information on using libraries on: September 15, 2014, 12:05:28 pm
I assume you can work out for your self that the library I am referring to is the matrix library in the arduino software i.e. maxmatrix but maybe I am wrong.
Yes, you are wrong.  I have never heard of the maxmatrix library and it is not installed on my system so how would I know ?

If I said that I was having problems with the servo library but failed to mention which of the many servo libraries that I was using then how would you know ?
2  Using Arduino / Programming Questions / Re: Crash debugging - RAM dump on: September 15, 2014, 06:26:19 am
The best you can do is to put Serial.prints at the start of each function indicating that the function has been called and perhaps printing the value of important variables, particularly those passed to the function, if any.  Similarly print the value of variables returned by the functions, if any, and the fact that the function has finished.

If the system crashes you can copy the Serial output and if you have formatted it suitably, perhaps using commas to created a CSV layout, you can paste it into Excel for analysis.
3  Using Arduino / Programming Questions / Re: For Loop Code Stepper Motor on: September 15, 2014, 06:19:29 am
I did not look too far before I found this
      if (error < 0);
The trailing semi-colon means that the test is effectively ignored.
4  Using Arduino / Programming Questions / Re: Variable question - way to code 'all variables except' ? (using []?) on: September 15, 2014, 01:24:45 am
Now that it works you could tidy up your program a bit more by making the measureDistance() function do what its name implies.  Put all of the code that calculates distance in the function so that by the time it has run distance is set to the target distance. 

For extra points have the function calculate the distance and return it to the main program rather than setting a global variable.  Not strictly necessary but good to learn the technique.

On a similar note, save space by changing several variables from ints to bytes when you know that there value cannot exceed 255.
5  Using Arduino / Programming Questions / Re: Time Alarm Not Working (With NTP) on: September 14, 2014, 03:16:45 pm
  if (alarm == false)
    Alarm.alarmRepeat(19, 35, 0, MorningAlarm);
    alarm = true;
    Serial.println("alarm set");
Do you get the message printed indicating that the alarm is set when you expect it ?  I hope it is obvious that an alarm set for a time of  19:35:00 will not be triggered in the morning despite the name of the function.
6  Using Arduino / Programming Questions / Re: What is best method to multiplex many buttons with only 2 interrupts available? on: September 14, 2014, 09:55:10 am
In my first Arduino Mega project I had 4 buttons that needed to have a fast hardware interrupt
How fast are these buttons being pressed and released and what is the shortest interval between pressing 2 different buttons ?

If you triggered the check for button presses using an interrupt then polled the buttons using digitalRead() it seems to me that you may as well have just polled them anyway.

Will I miss a button press reading pin state for 6 pins sequentially?
That depends on what else you are doing in loop() and how you are doing it.  Seeing your program would help.

To read the state of multiple buttons at once in loop() you could use an analogue input and a resistor ladder to give a different value  for each button.
7  Using Arduino / Programming Questions / Re: display all characters at once in serial monitor on: September 14, 2014, 04:24:07 am
As was pointed out in your other thread you are not clearing the value from the val variable after printing so when you add more characters to it no wonder that you get odd results.
8  Using Arduino / Programming Questions / Re: Arduino UNO and interrupts (strange things) on: September 13, 2014, 02:16:58 pm
void blink1() {             

void blink2() {             
Interrupts are automatically disabled when an ISR is called.   Serial.print() depends on interrupts.
As suggested, have the ISRs simply update a variable (declared as volatile),and move the Serial.prints outside of the ISRs and have the prints controlled by the value of the variable updated by the ISR.
9  Using Arduino / Programming Questions / Re: Time Alarm Not Working (With NTP) on: September 13, 2014, 11:50:21 am
Whatever else may or may not be wrong your alarms will not work because you have not taken note of this from the TimeAlarms readme and/or the TimeAlarms examples.

Your sketch should call the Alarm.delay() function instead of the Arduino delay() function when
using the Alarms library.  The timeliness of triggers depends on sketch delays using this function.
10  Using Arduino / Programming Questions / Re: Help with code using relay shield to power on/off my arcade cabinet. on: September 13, 2014, 11:31:39 am
You could do what you want by counting button presses but to my mind it would be simpler to set a boolean variable to true or false depending on whether the cabinet was powered on or not.

Start with the variable, let's call it poweredOn, set to false.  Detect the state change of switch state from off to on then, if poweredOn is false execute the code to turn the power on and set poweredOn to true else if poweredOn is true execute the code to turn the power off and set poweredOn to false.

You have quite rightly turned on the internal pullup resistor to avoid the switch input floating but in my opinion it is more explicit if you use
pinMode(mainSwitch, INPUT_PULLUP);

Edit : Changed INPUT to INPUT_PULLUP
11  Using Arduino / Programming Questions / Re: Help with code using relay shield to power on/off my arcade cabinet. on: September 13, 2014, 01:27:12 am
  if(digitalRead(mainSwitch) == LOW)  // main button is pressed.
You are sensing that the button is currently pressed rather than when it becomes pressed.  You need to sense the change from on to off, ie the change of state not the current state.

Look at the StateChangeDetection example in the IDE to see how to do it.
12  Using Arduino / Programming Questions / Re: Can someone point me to what data(2) references in the below code? on: September 12, 2014, 12:28:45 pm
in the code snippet below (which comes from the DHT.cpp library, there are references to data(2) and data(3)
Actually there are references to data[2] and data[3] which are the third and fourth elements of an array called data.

As you have not posted the complete program it is impossible to be more precise as to the contents and use of the array.
13  Using Arduino / Programming Questions / Re: error compiling !!! servo and rf :/ on: September 12, 2014, 12:23:19 pm
14  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.
15  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.
Pages: [1] 2 3 ... 288