Show Posts
Pages: [1]
1  Using Arduino / Programming Questions / Re: "Send tweet with timestamp" sketch hangs, shows no activity on: October 30, 2012, 01:14:50 pm
You may want to try calling Udp.stop() or Udp.flush() at the end of the NTP function.  If it is sending the first correctly but hanging after that, it sounds like a resource issue to me.  I've never tried this and maybe someone can verify, can you open EthernetUdp.cpp and add some Serial.println()'s to debug and see why its hanging there?
Code:
unsigned long sendNTPpacket(IPAddress& address)
{
  Serial.println("sendNTPpacket() begins!");
  // set all bytes in the buffer to 0
  memset(packetBuffer, 0, NTP_PACKET_SIZE);
  
  Serial.println("memset set!");
  // Initialize values needed to form NTP request
  // (see URL above for details on the packets)
  
    Serial.println("adding to packetBuffer!");
  
  packetBuffer[0] = 0b11100011;   // LI, Version, Mode
  packetBuffer[1] = 0;     // Stratum, or type of clock
  packetBuffer[2] = 6;     // Polling Interval
  packetBuffer[3] = 0xEC;  // Peer Clock Precision
  // 8 bytes of zero for Root Delay & Root Dispersion
  packetBuffer[12]  = 49;
  packetBuffer[13]  = 0x4E;
  packetBuffer[14]  = 49;
  packetBuffer[15]  = 52;

    Serial.println("packetBuffer set!");
  // all NTP fields have been given values, now
  // you can send a packet requesting a timestamp:  
  Udp.beginPacket(address, 123); //NTP requests are to port 123
  
    Serial.println("beginPacket set!");
  Udp.write(packetBuffer,NTP_PACKET_SIZE);
  
    Serial.println("write set!");
  Serial.print("NTP_PACKET_SIZE: ");
  Serial.println(NTP_PACKET_SIZE);
  
  
  Udp.endPacket();                              // << Code hangs here when I try to send a second tweet
  Serial.println("packet ended!");
  Serial.println("sendNTPpacket() ENDING!");
  Serial.println("");
  Udp.flush();
  Serial.println("Flush out Udp instance";
}
2  Using Arduino / Programming Questions / Re: button error on: October 25, 2012, 04:18:15 pm
there is a version for 1.0 available here http://github.com/tigoe/Button/archives/master
3  Using Arduino / Programming Questions / Re: button error on: October 25, 2012, 04:02:21 pm
I've never used the Button library, and its not referenced on the Arduino libraries page so I have no idea of its inner workings.  Where did you get it?  You might want to look into the Bounce library http://arduino.cc/playground/Code/Bounce
4  Using Arduino / Programming Questions / Re: Arduino IDE 1.01 preprocessor commands on: October 25, 2012, 03:55:50 pm
I declared my functions right after my include and now it works regardless of my defines.  Thanks for the help!
Code:
#include <Arduino.h>
void orangeLED();
void redLED();
void greenLED();
void LEDoff();

#define DEBUG 1
#define SQUELCH 0
...snipity do dah...
}
void orangeLED()
{
    //do stuff
}
...snipity day....
5  Using Arduino / Programming Questions / Re: button error on: October 25, 2012, 03:20:43 pm
If you are using the new version of the IDE you will need to remove the WProgram.h reference from the Button.h library.  Change that line to #include "Arduino.h".  Nick Gammon wrote a sticky that refernces this error. http://arduino.cc/forum/index.php/topic,97455.0.html
6  Using Arduino / Programming Questions / [SOLVED] Arduino IDE 1.01 preprocessor commands on: October 25, 2012, 03:11:50 pm
When I adjust my preprocessor commands (e.g. SQUELCH was defined as 1 then I changed it to 0) I get a bunch of errors such as:
Code:
ATCMUS.cpp: In function 'void setup()':
ATCMUS:19: error: 'orangeLED' was not declared in this scope
ATCMUS:32: error: 'LEDoff' was not declared in this scope
ATCMUS:37: error: 'LEDoff' was not declared in this scope
ATCMUS.cpp: In function 'void loop()':
ATCMUS:49: error: 'greenLED' was not declared in this scope
ATCMUS:67: error: 'redLED' was not declared in this scope
when they were just fine before. Why is it suddenly not seeing these functions.  I had the same errors with digitalWrite() and other basic arduino constructs (HIGH, LOW, INPUT, etc) until I included Arduino.h.  I've never had to seperately declare my functions (void orangeLED(); ) before and the preprocessors make it much easier for me to change the program based on my requirements.

Code below:
Code:
#include <Arduino.h>

#define DEBUG 1
#define SQUELCH 0

#if SQUELCH
  int potPin = A0; // select the input pin for the potentiometer
#endif

int sensorPin = A5;    
int rled = 6;
int gled = 8;
int relay = 2;
int overridepin = 9;

void setup()
{
  pinMode(rled, OUTPUT);
  pinMode(gled, OUTPUT);
  orangeLED(); //indicate setup
  pinMode(relay, OUTPUT);
  pinMode(sensorPin, INPUT);
  pinMode(overridepin, INPUT_PULLUP);
  #if SQUELCH
    pinMode(potPin,INPUT);
  #endif
  
  #if DEBUG
    Serial.begin(9600);
  #endif
  for (int i=0;i<4;i++)//warn setup finishing
  {
    LEDoff();
    delay(250);
    orangeLED();
    delay(250);
  }
  LEDoff();
}

void loop()
{
  float sensitivity = 0.00;
  int sensorValue = 0;
  int sensValold = 0;
  float diff = 0.00;
  
  if (digitalRead(overridepin)==LOW)
  {
    greenLED();
    digitalWrite(relay, LOW);
    
    #if DEBUG
      Serial.println("Override Engaged");
    #endif
    
    delay(2000);
  }
  else
  {
    #if SQUELCH
      [redacted]
    #else
      [redacted]
    #endif
    
    redLED();
    sensorValue = analogRead(sensorPin);
    diff = (float)(sensorValue - sensValold)/(float)(sensorValue);
    
    #if DEBUG
      Serial.println(abs(diff));
    #if SQUELCH
      Serial.print("Sensitivity: ");
      Serial.println(sensitivity);
    #endif
    #endif
    
    if (abs(diff) > sensitivity)
    {
      digitalWrite(relay, LOW);
      delay(2000);
    }
    else
    {  
      digitalWrite(relay, HIGH);
    }
    sensValold = sensorValue;
    delay(75);
  }  
}
void redLED()
{
  digitalWrite(rled,HIGH);
  digitalWrite(gled,LOW);
}
void greenLED()
{
  digitalWrite(gled,HIGH);
  digitalWrite(rled,LOW);
}
void orangeLED()
{
  digitalWrite(rled,HIGH);
  digitalWrite(gled,HIGH);
}
void LEDoff()
{
  digitalWrite(rled,LOW);
  digitalWrite(gled,LOW);
}
7  Using Arduino / Audio / Re: Priority Audio on: October 24, 2012, 02:08:08 pm
bumpity bump bump
8  Using Arduino / Programming Questions / Re: garage door opener on: October 23, 2012, 12:11:51 pm
Your go declaration for a char is two characters a char is only one char, I'm surpised it compiled with
Code:
char go = 'go';
  Also try changing the
Code:
digitalWrite(door, 1023);
   to
Code:
digitalWrite(door, HIGH);
9  Using Arduino / Audio / Re: Priority Audio on: October 19, 2012, 10:21:11 pm
Sorry, it took so long.  Here is my schematic.  I have connected the sleeve from the plug i want to sense to AGND (pin 22) since the tip is the positive side of the signal, that is connected to A5 (pin 28).  It would make my board layout so much simpler if i could connect AGND to GND, but I want to make sure I keep the signals isolated from the rest of the system.

10  Using Arduino / Programming Questions / Re: error: a function-definition is not allowed here before '{' token on: October 18, 2012, 09:02:16 am
Edit: Arrch beat me to it...
Code:
delay(100);

    while(cm <= 5){   //  Tant que la distance entre le parallax et ce qu'il détecte (c'est à dire l'eau) est de moins de 5 cm alors...
       digitalWrite(pompe,HIGH);  // On active la pompe
       if (cm >= 15)  {     // Si la distance entre le parallax ce qu'il détecte (c'est à dire l'eau) est de plus de 15 cm alors...  
       digitalWrite(pompe, LOW);      // On éteint la pompe
  
}

long microsecondsToInches(long microseconds)
{

The issue is that you never closed the braces from your if and while.  If the code is trying to do what I think, then the program will be stuck inside the while loop as cm will never change inside the loop but, Try this:
Code:
...SNIP...
delay(100);

    while(cm <= 5)
    {   //  Tant que la distance entre le parallax et ce qu'il détecte (c'est à dire l'eau) est de moins de 5 cm alors...
       digitalWrite(pompe,HIGH);  // On active la pompe
       if (cm >= 15)
       {     // Si la distance entre le parallax ce qu'il détecte (c'est à dire l'eau) est de plus de 15 cm alors...  
           digitalWrite(pompe, LOW);      // On éteint la pompe
       }
    }  
}

long microsecondsToInches(long microseconds)
{
...SNIP...
11  Using Arduino / Audio / Re: Priority Audio on: October 17, 2012, 09:58:39 am
I think I have solved my problem,  I'm using the arduino to sense a change in the primary audio line and drive a DPDT relay to switch between audio channels.  Should I connect all the sleeves to ground or is it ok to leave the sleeve's "floating", I wanted to keep the system as isolated as possible from the rest of the plane.  I connected the sleeve from the plane to AGND, and the tip to A5.  Will this cause any problems?
12  Using Arduino / Programming Questions / Re: Can I recover/retrieve a program from Ardunio Uno? on: October 17, 2012, 09:43:14 am
I remember having to do something like this back in college.  You can user avrdude to recover the hex, convert the hex to assembly ewww using the datasheet for the 328p, you then may be able to get the assembly into something that looks like C.  If you are familiar with the original code (since you wrote it I would hope so).  This should provide you with enough information to either reconstruct the original program or use it as a reference to start a new arduino program.  Google should be able to help you with working with assembly.
13  Using Arduino / Audio / Priority Audio on: September 17, 2012, 10:40:39 pm
I am a private pilot and would like to listen to music on my long cross country flights.  It is absolutely critical that the music is squelched when audio is received on the primary input from the plane's headphone jack.  Is it possible or necessary to use an arduino to mux the two lines and output the audio?
Pages: [1]