Show Posts
Pages: 1 2 3 [4] 5 6 ... 583
46  Using Arduino / Project Guidance / Re: Implement octave shift buttons code? on: July 26, 2014, 08:25:13 pm
If anybody can help me with just an example of how you can implement the concept of octave up and down into the code I already have, this would be greatly appreciated. I just can't fathom it!

PLEASE!! smiley-cry

There are lots of tutorials about reading buttons and debouncing the signal (mechanical buttons tend to bounce a few times on closing).  Use a variable to keep track of which octave.  Use buttons to go up and down.  Add some checks so that you don't go outside your desired range of octaves.
47  Using Arduino / Storage / Re: arduino and excel on: July 24, 2014, 08:50:56 pm
Depends on what you mean by "lots of data".  The FLASH (program) memory can contain about 30,000 bytes.  Of course your program has to share that space so much more than about 20,000 bytes and you should consider external memory like an SD card or an EEPROM or FRAM chip.
48  Using Arduino / Installation & Troubleshooting / Re: how can I program a pro mini arduino on: July 24, 2014, 08:46:46 pm
Yes.
49  Using Arduino / LEDs and Multiplexing / Re: Trying to make simple LED Light for Aquarium on: July 24, 2014, 11:42:59 am
Here is a sketch I wrote to do a 2 hour fade between lighting levels on a schedule.  It doesn't use delay() so it should play nicely with your LCD display.  It can do a separate schedule on each PWM pin.

Code:
#include "Wire.h"
#define DS1307_ADDRESS 0x68  // This is the I2C address

const int Blue1Pin = 3;
const int Blue2Pin = 5;
const int White3Pin = 6;
const int White4Pin = 9;
const unsigned long HOUR = 60 * 60;
const unsigned long MINUTE = 60;
const int TARGET_BRIGHTNESS = (255 * 3) / 4;  // Target brightness is 3/4 of full

void setup()
{
  Wire.begin();
}

byte bcdToDec(byte val)  {
  // Convert binary coded decimal to normal decimal numbers
  return ( (val/16*10) + (val%16) );
}

void loop()
{
  /////  Get time from RTC into RTCHour, RTCMinute, RTCSecond

  // Set the register pointer to 0 (Second)
  Wire.beginTransmission(DS1307_ADDRESS);
  Wire.write((byte)0);
  Wire.endTransmission();

  //  Read Second, Minute, and Hour
  Wire.requestFrom(DS1307_ADDRESS, 3);

  int RTCSecond = bcdToDec(Wire.read());
  int RTCMinute = bcdToDec(Wire.read());
  int RTCHour = bcdToDec(Wire.read() & 0b111111); //24 hour time


  unsigned long time = RTCHour * HOUR + RTCMinute * MINUTE + RTCSecond;  // Time in seconds

  // For each lighting channel calculate new brightness.  Fades take 2 hours.  
  // Pass the time that the fade-in starts and the time the fade-out starts

// Fade in at 7 AM and out at 5 PM
  analogWrite(Blue1Pin,   brightness(time, 7*HOUR,                 17*HOUR));

// Fade in at 7:30 AM and out at 4:30 PM
  analogWrite(Blue2Pin,   brightness(time, 7*HOUR+30*MINUTE, 16*HOUR+30*MINUTE));

// Fade in at 8 AM and out at 3 PM
  analogWrite(White3Pin, brightness(time, 8*HOUR,                 15*HOUR));

// Fade in at 9 AM and out at 2 PM
  analogWrite(White4Pin, brightness(time, 9*HOUR,                 14*HOUR));
}

byte brightness(unsigned long time, unsigned long fadeUpStart, unsigned long fadeDownStart)
{
  //  Mid day, light is at maximum brightness
  if (time >= fadeUpStart + 2*HOUR  && time <= fadeDownStart)
    return TARGET_BRIGHTNESS;

  // Dawn:  fade up the light
  if (time >= fadeUpStart && time <= fadeUpStart + 2*HOUR)  // Fading up
  {
    unsigned long seconds = time - fadeUpStart;  // Number of seconds into the fade time
    return TARGET_BRIGHTNESS * seconds / (HOUR*2);  // Fade up based on portion of interval completed.
  }

  // Evening: Fade down the light
  if (time >= fadeDownStart && time <= fadeDownStart + 2*HOUR)  // Fading down
  {
    unsigned long seconds = (fadeDownStart + (HOUR*2)) - time;  // Number of seconds remaining in the fade time
    return TARGET_BRIGHTNESS * seconds / (HOUR*2);  // Fade down based on portion of interval left.
  }

  // The remaining times are night and the lights is off
  return 0;  // Shouldn't get here
}
50  Using Arduino / Networking, Protocols, and Devices / Re: wifi udp write is truncating packets to 29 bytes on: July 24, 2014, 11:27:16 am
Maybe you have to change this line in WiFiUDP.h:
Code:
#define UDP_TX_PACKET_MAX_SIZE 24
51  Using Arduino / Project Guidance / Re: Making multiple POST requests on: July 24, 2014, 08:17:42 am
OK, that's the sketch where you didn't try to send a POST in loop().  What does the sketch where you DID try to send a POST in loop() look like and in what way is it not working as desired?
52  Using Arduino / Motors, Mechanics, and Power / Re: arduino micro + peltier module + h bridge + LM35 on: July 24, 2014, 08:11:54 am
Don't Peltier modules draw a LOT of current?  I hope you have a very hefty 9V battery.

An Arduino will run on 3V but at 16 MHz you should not feed it less than 3.7V.  You can run at 8 MHz down to 2.4V:

https://docs.google.com/spreadsheet/ccc?key=0AmrQPFjOzdMsdF9TNFN2Rkp4WTVmeUdMLXdMSDJJU1E&usp=docslist_api#gid=0
53  Using Arduino / Networking, Protocols, and Devices / Re: SPI problem/SD card/DS3234 on: July 24, 2014, 06:44:28 am
Hi, I have the same problem, but I don't understand very well how to resolve this problem ?

Use this library instead of the built-in SD library:
The new version of SdFat:
     http://code.google.com/p/sdfatlib/downloads/list
54  Topics / Robotics / Re: help with my arduino program! on: July 23, 2014, 08:13:27 pm
Hi, I have some doubts with the arduino program.
My objective is to control 5 servo motors with one button each.

Use arrays, like this:
Code:
#include <Servo.h>

const int ButtonCount = 5;

const int servoPins[ButtonCount] = {
  3,5,7,9,11};
const int buttonPins[ButtonCount] = {
  2,4,6,8,10};

int buttonStates[ButtonCount];    //Variable para leer el estado del pulsador
int directionStates[ButtonCount]; //Variable para leer la dirección del servo 1

Servo myservos[ButtonCount]; //Crear el objeto servo para controlar el servo

int positions[ButtonCount];   //Variable para almacenar la posición del servo

void setup() {
  for (int i=0; i<ButtonCount; i++) {
    myservos[i].attach(servoPins[i]);         //Conectar servo al pin 3
    pinMode(buttonPins[i], INPUT); //Iniciar pin del boton como entrada
  }
}

void loop() {
  for (int i=0; i<ButtonCount; i++) {
    //lee el estado del valor del boton
    buttonStates[i] = digitalRead(buttonPins[i]);

    if (directionStates[i] == 0) {
      //boton presionado
      if(buttonStates[i] == HIGH) {
        directionStates[i] = 1;    //la direccion del servo es a la derecha

        //va desde 0 grados a 180 grados en pasos de 1 grado
        for(positions[i] = 0; positions[i] < 180; positions[i]++) {
          myservos[i].write(positions[i]);  //Dice al servo que valla a la posicion de la variable ¨pos¨
          delay(15); // espera 15ms para que el servo llegue a su posición
        }
      }
    }
    else if (directionStates[i] == 1) {
      // boton presionado
      if (buttonStates[i] == HIGH) {
        directionStates[i] = 0;    // la dirección del servo es a la izquierda

        // va de 180 grados a 0 grados en pasos de 1 grado
        for(positions[i] = 180; positions[i]>=1; positions[i]--) {
          myservos[i].write(positions[i]);  //dice al servo que valla a la posición de la variable ¨pos¨
          delay(15);           //Espera 15ms para que el servo llegue a su posición
        }
      }
    }
  }
}
55  Using Arduino / Project Guidance / Re: Frequency Measurement of a Guitar String. on: July 23, 2014, 05:15:07 pm
Maybe average 10 readings, throwing out any data points more than 10% below the current average?

Code:
   float average = getFrequency();
   for (int i=1; i<=10; ) {
      float frequency = getFrequency();
      if (frequency < (0.9 * (average/i)))
           continue;  // Skip this sample
      average += frequency;
     i++;
    }
56  Using Arduino / LEDs and Multiplexing / Re: Can a ULN2803APG drive a 12V led strip with 440ma load? on: July 23, 2014, 03:53:19 pm
There is a chart in the datasheet showing output current vs. duty cycle with all outputs active.  I think that it is showing that you can get 440 mA out but only at about 5% duty cycle.   At 100% duty cycle the output current drops to about 60 mA. 

Perhaps some logic level power MOSFETs would handle the current better.
57  Using Arduino / Displays / Re: Reprogram Default Character Set on: July 23, 2014, 11:47:29 am
I didn't see anything in the the datasheet about restoring the character NVM (EEPROM).  I suspect you will have to find the data somewhere and upload it.

Looks like the evaluation kit includes defaultCM.mcm which contains the default character set:
http://pdfserv.maximintegrated.com/en/ds/MAX7456EVKIT.pdf
58  Using Arduino / Networking, Protocols, and Devices / Re: Connecting my GPS to the Arduino on: July 23, 2014, 11:28:31 am
Some people have had problems with the serial receive buffer being too small to hold the whole message. You may want to edit this line in SoftwareSerial.h:
Code:
#define _SS_MAX_RX_BUFF 64 // RX buffer size
59  Using Arduino / Networking, Protocols, and Devices / Re: Connecting my GPS to the Arduino on: July 23, 2014, 08:39:13 am
Does the GPS have a clear view of the sky?
60  Using Arduino / Project Guidance / Re: Content length? on: July 23, 2014, 08:28:26 am
"The Content-Length entity-header field indicates the size of the entity-body, in decimal number of OCTETs, sent to the recipient or, in the case of the HEAD method, the size of the entity-body that would have been sent had the request been a GET."

Sounds like you should be counting the line endings, too.
Pages: 1 2 3 [4] 5 6 ... 583