Show Posts
Pages: [1]
1  Using Arduino / Programming Questions / Re: Leonardo fails to be detected with attachInterrupt() and Serial.begin() on: February 24, 2014, 05:23:44 am
Correct. It is not re-discovered as a valid USB device. Same issue on two Leonardo boards.

In my initial post, the sketch has been uploaded and the Arduino reset.
At 17:04:58 it is detected as a USB device, but the following syslog lines from 17:05:06 until 17:05:08 are errors from the USB layer in Linux when the program starts up. After this I no longer have a /dev/ttyACM to talk to.
2  Using Arduino / Programming Questions / Re: Leonardo fails to be detected with attachInterrupt() and Serial.begin() on: February 23, 2014, 04:45:27 pm
I added the loop for the serial port, and while that is a helpful comment, it unfortunately doesn't help against the disappearing USB device.
Same symptom; I plug the Arduino in and once the program is running I get the messages in syslog that I initially posted and can no longer talk to it. If I try to open the Serial Monitor in the IDE there is no port for it to communicate with.

Anyone else with some suggestions how I can use interrupts and USB serial in the same sketch on Leonardo?
3  Using Arduino / Programming Questions / Re: Leonardo fails to be detected with attachInterrupt() and Serial.begin() on: February 23, 2014, 12:27:22 pm
Let's ignore the problem of actually using the interrupt for something, I'll get there once I don't lose contact with /dev/ttyACM0 as soon as the program is running. Any idea why that is happening?
I wanted to show that if you upload the sketch into an Arduino Leonardo it stops behaving like it used to seen from the computers USB point of view, and that's where I don't understand how I went wrong.
4  Using Arduino / Programming Questions / Leonardo fails to be detected with attachInterrupt() and Serial.begin() on: February 23, 2014, 12:00:09 pm
I am trying to make an Arduino count pulses via an interrupt and output the number over serial line (USB) to a computer.
I got everything to work with an Uno, but since it resets every time something connects to the USB I decided to use a Leonardo.
Here I understand that both interrupts and serial ports are slightly different. I still don't understand why this simple sketch causes problems. I have removed any attempts at actually output data on the serial port in the example code.
Pin 13 is the LED, interrupt 0 should be pin 3 on the Leonardo. No pins are connected to anything yet, so I can trigger the interrupt
just by touching the solder around the pin on the board.

Code:
// pin for LED
#define LEDpin 13

// pin for interrupt
#define IRintr 0

// state change
volatile int state = HIGH;

// the rotation counter - number of rotations seen
volatile int rotations=0;


void setup() {

  // enable LED
  pinMode(LEDpin, OUTPUT);

  // use pin 0 for interrupts, triggered on falling level
  attachInterrupt(IRintr, blink, LOW);

  Serial.begin(9600); // serial output
}

void loop() {

  digitalWrite(LEDpin, state);

}


void blink()
{
    state = !state;
    rotations++;

}



When I upload the sketch, my syslog shows that the Leonardo is no longer recognized after a few seconds:

Feb 23 17:04:58 linux1 mtp-probe: checking bus 4, device 82: "/sys/devices/pci0000:00/0000:00:1d.2/usb4/4-1"
Feb 23 17:04:58 linux1 mtp-probe: bus: 4, device: 82 was not an MTP device
Feb 23 17:05:06 linux1 kernel: [251091.472084] usb 4-1: USB disconnect, device number 82
Feb 23 17:05:06 linux1 kernel: [251091.808075] usb 4-1: new full-speed USB device number 83 using uhci_hcd
Feb 23 17:05:06 linux1 kernel: [251091.932060] usb 4-1: device descriptor read/64, error -71
Feb 23 17:05:07 linux1 kernel: [251092.160064] usb 4-1: device descriptor read/64, error -71
Feb 23 17:05:07 linux1 kernel: [251092.376057] usb 4-1: new full-speed USB device number 84 using uhci_hcd
Feb 23 17:05:07 linux1 kernel: [251092.500063] usb 4-1: device descriptor read/64, error -71
Feb 23 17:05:07 linux1 kernel: [251092.728059] usb 4-1: device descriptor read/64, error -71
Feb 23 17:05:07 linux1 kernel: [251092.944063] usb 4-1: new full-speed USB device number 85 using uhci_hcd
Feb 23 17:05:08 linux1 kernel: [251093.360042] usb 4-1: device not accepting address 85, error -71
Feb 23 17:05:08 linux1 kernel: [251093.472056] usb 4-1: new full-speed USB device number 86 using uhci_hcd
Feb 23 17:05:08 linux1 kernel: [251093.888059] usb 4-1: device not accepting address 86, error -71
Feb 23 17:05:08 linux1 kernel: [251093.888102] hub 4-0:1.0: unable to enumerate USB device on port 1

Happens every time I reset, the delay appears to be from the Arduino is plugged in to the program (sketch) is running.
I can press the reset button and upload a new sketch before the error occurs.


How can I configure one pin for interrupts and output to USB serial on the Arduino Leonardo?
5  Using Arduino / LEDs and Multiplexing / Another LED dimmer project on: February 05, 2011, 01:05:30 pm
I have bought a few of these LED strips:
http://www.dealextreme.com/details.dx/sku.41016

12V/1.8W - each strip has 12 blue 5050 LEDs

I want to use these in an aquarium as a moonlight. To get even lighting, I may use 2 or even 4 strips dimmed down.
Now, 1.8 watts at 12V is .15A = 150mA for each strip, right?

What components do I use between the Arduino and these if I want to avoid damaging both parts? I will get a couple of 3021 BuckPucks for some other experiments, but is this "overkill" just to run up to 4 of these strips?

I also have some ULN2003A, can I connect that to PWM and run a constant current source such as http://www.dealextreme.com/details.dx/sku.13557?

6  Forum 2005-2010 (read only) / Syntax & Programs / Ethernet shield returning garbage characters on: November 08, 2009, 03:31:31 pm
I have tried to expand one of the Ethernet examples so I can receive several characters - e.g. for sending commands to an Arduino over the net. For some reason, the client always recieves the same 27 rubbish characters when I run this program. Is there a buffer I didn't clear out or am I doing something wrong?
I have tried this with Arduino 15,16 and 17 on Linux.
The serial output shows that the myword[] array gets the 27 characters as input when the program is started.
I have also tried a different sketch that doesn't disconnect the client, this shows that it is only when the Arduino starts up that this happens.

Code:
#include <Ethernet.h>

// network configuration.  gateway and subnet are optional.
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 192, 168, 1, 170 };
byte gateway[] = { 192, 168, 1, 1 };
byte subnet[] = { 255, 255, 255, 0 };

// telnet defaults to port 23
Server server(23);

char c;
char myword[40];
int i;

void setup()
{
    // initialize the ethernet device
    Ethernet.begin(mac, ip, gateway, subnet);
    Serial.begin(9600); // DEBUG only
    //initArray();
    // start listening for clients
    server.begin();

}

void loop()
{
  Client client = server.available();
  if (client) {
    // an http request ends with a blank line
    boolean current_line_is_blank = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        // if we've gotten to the end of the line (received a newline
        // character) and the line is blank, the http request has ended,
        // so we can send a reply
        if (c == '\n' && current_line_is_blank) {
          // output the content
          for (int l = 0; l < sizeof(myword); l++) {
            client.print(myword[l], BYTE);
            Serial.print(myword[l]);
          }
          client.flush();
          i=0;
          initArray();
          client.stop();
          // client.print(sizeof(myword));
          break;
        }
        if (c == '\n') {
          // we're starting a new line
          current_line_is_blank = true;
        } else if (c != '\r') {
          // we've gotten a character on the current line
          myword[i++]=c;
          Serial.print("Storing character\t");
          Serial.print(c);
          Serial.print("\tin array\t");
          Serial.print(i);
          Serial.print("\n");
          current_line_is_blank = false;
        }
      }
    }
    //client.stop();
    //initArray();
    //i=0;
    
  }
  
   //client.stop();
    //initArray();
    //i=0;
}

int initArray() {
for(int n=0;n<40;n++){
      myword[n]=' ';
      Serial.print("Now resetting number:\t");
      Serial.print(n);
      Serial.print("\n");
}
}
7  Forum 2005-2010 (read only) / Syntax & Programs / Trying to learn ethernet communication on: August 31, 2009, 03:22:38 pm
I have a Duemilanove with an ethernet shield. I have tried the basic examples, but I need some way of handling the incoming data. Any examples for how you can send a string with a number over telnet (e.g. "123") and interpret it as numeric data?

I assume you need to read one byte at a time and add them to a char array?

Some examples with difficulty in between the "chat" echo repeater and a full web server would be nice to have.
8  Forum 2005-2010 (read only) / Troubleshooting / Re: Sensitivity of inputs? on: September 08, 2010, 12:09:55 pm
Thank you!
I connected an IR diode+sensor (Lynxmotion SLD-01) and added some debounce to the code. Everything appears to work as it should now - and I learned a few things at the same time.
Again, thanks for helping me out.
9  Forum 2005-2010 (read only) / Troubleshooting / Sensitivity of inputs? on: September 08, 2010, 06:11:36 am
I have a Duemilenova board which I can program and use normally. However, I sometimes have strange results that I suspect is beyond my poor coding.

I tried uploading the example sketch for attachInterrupt() which blinks the LED based on the state of a digital input. I have set it to trigger on falling level, and without connecting anything to the board the LED flashes madly if I just touch the outside plastic of the black connectors or lift the board my the USB cable and move it around.

Is my Arduino overly sensitive, or is this expected behaviour? I did expect a bit more noise protection for a digital input, and I am not sure how to control this.
Pages: [1]