Show Posts
Pages: [1] 2 3 ... 66
1  Using Arduino / Programming Questions / Re: Looping LED patterns and using a button to break the loop on: July 22, 2014, 08:07:12 pm
You have been asked to post some code, and you have been told that your question is too vague... You didn't post code or explained what you want to do, so no one can help you... smiley
2  Using Arduino / Programming Questions / Re: Help to simplify code - CapacitiveSensor on: July 22, 2014, 09:26:32 am
But don't forget he is obviously a beginner, also, using malloc in loop() is really a bad idea.
3  Using Arduino / Programming Questions / Re: Help to simplify code - CapacitiveSensor on: July 22, 2014, 09:05:44 am
Why so complex? smiley-eek

Code:
#include <CapacitiveSensor.h>

const uint8_t NUM_SENSORS = 3;

CapacitiveSensor cs[NUM_SENSORS] =
{
  CapacitiveSensor(2,3),
  CapacitiveSensor(2,4),
  CapacitiveSensor(2,5)
};

int TSW[NUM_SENSORS];
long SW[NUM_SENSORS];

void setup()                    
{
   cs[0].set_CS_AutocaL_Millis(0xFFFFFFFF);    
   Serial.begin(9600);
}

void loop()                    
{
  for ( uint8_t i = 0; i < NUM_SENSORS; i++ )
  {
    SW[i] =  cs[i].capacitiveSensor(30);

    if (SW[i] > 500)
    {
      TSW[i] ++;
      //Serial.println(TSW[i]);
      if (TSW[i] == 5)
      {
        Serial.print("SW ");
        Serial.print( i );
        Serial.println( " on");
      }
    }
    else TSW[i] = 0;
  }
}

Next step would be to use a struct...
4  Using Arduino / Programming Questions / Re: Help to simplify code - CapacitiveSensor on: July 22, 2014, 08:29:19 am
Hello,

A for loop is what you need smiley
5  Using Arduino / Programming Questions / Re: How can I send and recive multiple values over serial? on: July 22, 2014, 08:10:37 am
Hello and welcome,

Here is an example how I would do it:
Code:
void loop()
{
  if ( Serial.available() > 0 )
  {
    static char input[64];
    static uint8_t i;
    char c = Serial.read();

    if ( c != '\r' && i < 64-1)
      input[i++] = c;

    else
    {
      input[i] = '\0';
      i = 0;
      
      char c;
      uint8_t v;
      
      if ( sscanf(input, "%c%hhu", &c, &v) == 2 )
      {
        switch( tolower(c) )
        {
          case 'r':
          {
            Serial.print("Setting PWM on Red to: ");
            Serial.println( v );
            analogWrite( ledR, v );
            break;
          }
          case 'g':
          {
            Serial.print("Setting PWM on Green to: ");
            Serial.println( v );
            analogWrite( ledG, v );
            break;
          }
          case 'b':
          {
            Serial.print("Setting PWM on Blue to: ");
            Serial.println( v );
            analogWrite( ledB, v );
            break;
          }
        }
      }
    }
  }
}

If you want a more robust code, read this: http://www.gammon.com.au/serial (especially, the reply #1)
6  Using Arduino / Programming Questions / Re: Millis()? on: July 21, 2014, 11:05:20 pm
Also, be careful with wrap around.

If "lastTime" is an unsigned long, that will not be a problem at all smiley-wink

http://playground.arduino.cc/Code/TimingRollover
7  Community / Exhibition / Gallery / Re: Programming DS3231 Alarms and Interupts on: July 21, 2014, 10:49:34 pm
Thank you, I have a DS3231 too, while I don't need alarms or interrupts yet, it might be helpful in the future smiley-wink

Since you didn't include the library that you used in those sketches, here is a link to it (I suppose it's this one, right?): http://forum.arduino.cc/index.php/topic,57642.0.html
8  Using Arduino / Programming Questions / Re: My EEPROM data kept resetting =( on: July 21, 2014, 10:33:31 pm
@ Guix,  Which pin on an Arduino is PIC?

smiley Sorry but that's the first picture that I found, showing difference between active low and active high.
9  Using Arduino / Programming Questions / Re: My EEPROM data kept resetting =( on: July 21, 2014, 10:25:15 pm
I may be wrong, but it appears to me that your button wiring is incorrect, it should be like this (in your case, active low):
10  Using Arduino / Programming Questions / Re: Looping LED patterns and using a button to break the loop on: July 21, 2014, 09:49:20 pm
Your arduino isn't multithreaded, so you must avoid blocking code (such as while() and delay()).
11  Using Arduino / Programming Questions / Re: Looping LED patterns and using a button to break the loop on: July 21, 2014, 09:36:09 pm
Hello,

Post your code. I suspect that you are using delays for your sequences. Right?
12  Using Arduino / Programming Questions / Re: My EEPROM data kept resetting =( on: July 21, 2014, 09:15:48 pm
Hello,

You say you have the problem since you added the RTC... And then you say if you remove the code for the button, it works... So I'm a bit confused.

If the problem is your button code: How is your button wired? Are you sure you wired it so it reads LOW when pressed ?

Also, still about that button, you should debounce it properly: http://arduino.cc/en/Tutorial/Debounce

Or, as you are using many big delays, you should look into using interrupts to catch every button presses, because actually your code won't catch button presses while the code is delayed... Or yet better, get rid of those delays and use non blocking code instead smiley
13  Using Arduino / General Electronics / Re: eeprom- help on: July 21, 2014, 07:41:10 pm
No idea, I think that with an 16Mhz Arduino, speeds would be very similar, but I can be wrong.  smiley-kitty
14  Using Arduino / General Electronics / Re: eeprom- help on: July 21, 2014, 04:10:43 pm
If you are talking about Chip Select, then yes, in the datasheet they call it CE (Chip Enable).

And this isn't an EEPROM, this is Flash memory. Main difference is: with the EEPROM you can erase one byte, but with the Flash, you can't erase just one byte, you have to erase a whole sector (in the case of this chip, the smallest sector size is 4KB).

If you absolutely want an EEPROM, I doubt you will find one with a size greater than 1MB (but I can be wrong).
15  Using Arduino / General Electronics / Re: eeprom- help on: July 21, 2014, 12:23:30 am
I have used this library: https://github.com/LowPowerLab/SPIFlash

If you look at the provided example, you will see that when creating the SPIFlash object, it require optionally a manufacturer ID (but IIRC, in my case it didn't work without it no in fact it worked without it, it's just to make sure that the flash chip being talked to, is of the correct type).

For the SST25VF032B, the manufacturer ID was 0xBF25. I don't remember how I found this ID, I think it was somewhere in the datasheet.

Oh and I forgot to say, this chip must be powered by 2.7-3.6V (including the SPI). NOT 5V. So you may need level shifters, depending on your Arduino board.
Pages: [1] 2 3 ... 66