Show Posts
Pages: [1] 2 3 ... 15
1  Using Arduino / Programming Questions / Re: Code help on: October 09, 2012, 07:10:45 pm
Code:
void LcdString(const char characters[])
{
  LcdString((char*)characters);
}

You are missing your overloaded function.
2  Using Arduino / Programming Questions / Re: Push button switch program on: April 20, 2012, 01:21:18 am
I would approach the program a bit differently...

I'd try a set up more like
Code:
int button_pushed(void)
{
   // See if button is pushed
   if (digitalRead(2))
   {

      // Wait for bouncing
      delay(20);

      // if button still pushed
      if (digitalRead(2))
      {
         return 1;
      }

   }

   return 0;    
}

And in the main loop...

Code:
/* Wait for button to be pushed */
while (!button_pushed());
 
/* Turn on LED */
digitalWrite(ledpin, HIGH);

/* Wait for button to be let go */
while (button_pushed());

/* Wait for button to be pushed */
while (!button_pushed());
 
/* Turn off LED */
digitalWrite(ledpin, LOW);

/* Wait for button to be let go */
while (button_pushed());


3  Using Arduino / Programming Questions / Re: bitwise problem on: August 25, 2011, 06:36:39 pm
I usually just use () for readability; even if they are not needed.

i.e.
if( a+b <= MAGIC_NUMBER/2) ...

I would type...
if( (a + b) <= (MAGIC_NUMBER / 2) )...

4  Using Arduino / Programming Questions / Re: bitwise problem on: August 25, 2011, 06:31:13 pm
This is from "The Complete Reference: C++", Table 2-8 "The Precedence of C Operators"

Highest:
()[]->
!~++--(type)*&sizeof
*/%
+-
<<>>
< <= > >=
== =!
&^
|
&&
||
Highest:
?:
= += -= *= /= etc.
Lowest:
,
5  Using Arduino / Programming Questions / Re: bitwise problem on: August 25, 2011, 06:15:48 pm
Quote
Does MODULO refer to the remainder of a division calculation?

yes.
6  Using Arduino / General Electronics / Re: Op-amps on: August 23, 2011, 06:33:57 pm
The reason that I asked what the voltages on the inputs are is because you need to see if the other components are behaving as expected.

Looking at your circuit, you are just making a comparator - What voltages are you getting on the negative and positive input
7  Using Arduino / Programming Questions / Re: Handling timer overflow and compare interrupts in ATMega328 on: August 23, 2011, 06:24:37 pm
I usually find that I need to read the sections of the data sheet a few times before I understand it.

This isn't what you are doing, but it may be a good starting point.  The order you do things sometimes make a big difference:  I noticed that you initiate the timer interrupt before setting it up properly (TIMSK2).

This is working code that uses timer 2, and interrupts every 10 microseconds.  Try starting with this and then modifying it to what you want:

Code:
void SetupTimerISR() {
  // Disable interrupts while setting registers
  cli();

  // Reset control registers
  TCCR2A = 0;
  TCCR2B = 0;

  // Clear Timer on Compare Match (CTC) Mode
  TCCR2A |= (1 << WGM21);

  // Prescaler x1
  TCCR2B |= (1 << CS20);

  // Interrupt every 160/16e6 = 10 usec
  OCR2A = 159;

  // Use system clock for Timer/Counter2
  ASSR &= ~(1 << AS2);

  // Reset Timer/Counter2 Interrupt Mask Register
  TIMSK2 = 0;

  // Enable Output Compare Match A Interrupt
  TIMSK2 |= (1 << OCIE2A);

  // Enable interrupts once registers have been update
  sei();
}

// This ISR is run when Timer/Counter2 reaches OCR2A
ISR(TIMER2_COMPA_vect)
{
  int_count++;
}

Every 10 microseconds, a global variable increments.

8  Using Arduino / Programming Questions / Re: Handling timer overflow and compare interrupts in ATMega328 on: August 23, 2011, 04:21:03 am
And you've read through section 17 of the data sheet?
9  Using Arduino / General Electronics / Re: RFID Reader ID-20 from Sparkfun = Any hope left? on: August 22, 2011, 10:20:13 pm
  If you have gone over your current set up (both code and hardware)- double checking everything, and it still doesn't work, you'd have good reason to suspect that it is broken.

  If it is still working and you have gotten something wrong in your current set up, it would be the things that you have changed and may have bumped.  Get a multimeter and check that voltages are expected values.

  If you still can't get it working, you'll need to buy a new one.  If the new one works, than you'll know for sure!
10  Using Arduino / General Electronics / Re: Op-amps on: August 22, 2011, 09:50:50 pm
What voltages are you reading on the inputs?
11  Using Arduino / Programming Questions / Re: Serial transmission with dynamic buffer on: August 22, 2011, 09:30:43 pm
You can use the command malloc() for dynamic memory applications - However, as to my understanding, you should not.  The reason for this is that it may (for the lack of a better word) clash with the stack.  This will be an almost impossible thing to debug and crippling to your application.

Your best bet is to have a fixed buffer size.
12  Using Arduino / Programming Questions / Re: A/D converter with 0 to 1023 binary output on: August 22, 2011, 09:12:24 pm
just some pseudo for you:

if analogue value is above 1000000000:
  minus 1000000000 and turn on pin 11...

if analogue value is above 0100000000:
  minus 0100000000 and turn on pin 10...

... ect
13  Using Arduino / Programming Questions / Re: Interrupt Question on: August 22, 2011, 08:55:57 pm
Interrupts can be tricky.  However; I don't think that you should avoid them all together, because they can be useful in multitasking.

Try declaring "setting" as:

volatile int setting = 0;

[edit] Sorry, I didn't see that AWOL already suggested that in post #2 [/edit]
14  Using Arduino / Programming Questions / Re: Handling timer overflow and compare interrupts in ATMega328 on: August 22, 2011, 08:42:50 pm
I think that this will help you:
http://arduino.cc/en/Tutorial/SecretsOfArduinoPWM
15  Using Arduino / Programming Questions / Re: Pro Mini, no communication on: August 22, 2011, 02:00:10 am
This is a long shot - But have you turned all Bluetooth programs/hardware off?

This has traditionally caused problems with Arduino software.
Pages: [1] 2 3 ... 15