Show Posts
Pages: 1 2 [3] 4 5 ... 13
31  Using Arduino / Programming Questions / Re: Control flow troubles on: December 10, 2012, 08:22:21 am
Thank you!
32  Using Arduino / Programming Questions / Control flow troubles on: December 10, 2012, 08:05:41 am
I'm building a simple EEPROM programmer that allows me to set individual bytes. The idea is to be able to enter an address on the serial monitor, then the data. I managed to cobble a sketch together which does not work properly. The sketch should take any number entered and turn it into a byte, then set 8 digital outputs (pin 2-9) with the individual bits. My only worry is that the sketch does set the first pin (pin 2) but the rest of them. I think the for loop is executed only once. What am I doing wrong?

Code:
char inData[10];
int index, i;
boolean started = false;
boolean ended = false;

int AP[8] = {
  2,3,4,5,6,7,8,9};
int AD[8] = {
  0,0,0,0,0,0,0,0};

void setup(){
  Serial.begin(9600);
  Serial.println("ready");
  for (i=0;i<8;i++) {
    pinMode(AP[i],OUTPUT);
  }
  // Setup Data Pins
  for (i=0;i<8;i++) {
    pinMode(AD[i],OUTPUT);
  }
}

void loop()
{
  while(Serial.available() > 0)
  {
    char aChar = Serial.read();
    if(aChar == '>')
    {
      started = true;
      index = 0;
      inData[index] = '\0';
    }
    else if(aChar == '<')
    {
      ended = true;
    }
    else if(started)
    {
      inData[index] = aChar;
      index++;
      inData[index] = '\0';
    }
  }

  if(started && ended){
    int inInt = atoi(inData); // Convert the string to an integer
    for(int j=0; j<8; j++){
      int b = bitRead(inInt,j);
      Serial.println(b);
      if((b&bit(j))>0) {
        AD[j]=HIGH;
      }
      else {
        AD[j]=LOW;
      }      
      digitalWrite(AP[j],AD[j]);
      delay(100);
    }
    Serial.println(" ");
    // Get ready for the next time
    started = false;
    ended = false;
    index = 0;
    inData[index] = '\0';
  }
}





33  Using Arduino / Programming Questions / Re: Store Multiple Digit Input from Keypad on: December 10, 2012, 05:57:45 am
Brilliant, thanks! It's working.
34  Using Arduino / Programming Questions / Re: Store Multiple Digit Input from Keypad on: December 10, 2012, 05:50:01 am
This is what I get on the monitor if I enter an 8-digit number starting and finishing with the characters < and >:


inData: []
inData: []
35  Using Arduino / Programming Questions / Re: Store Multiple Digit Input from Keypad on: December 10, 2012, 04:04:20 am
For instance if I enter <12345> I get zero back. What am I doing wrong?
36  Using Arduino / Programming Questions / Re: Store Multiple Digit Input from Keypad on: December 10, 2012, 04:03:37 am
I've been looking for a solution for being able to enter multiple digit numbers and convert them into integer. I found a piece of code form PaulS but it does not work properly. Whatever number I enter with the delimiters I get '0' back on the serial monitor. The code:

Code:
char inData[10];
int index;
boolean started = false;
boolean ended = false;

void setup(){
  Serial.begin(9600);
  Serial.println("ready");
}

void loop()
{
  while(Serial.available() > 0)
  {
    char aChar = Serial.read();
    if(aChar == '>')
    {
      started = true;
      index = 0;
      inData[index] = '\0';
    }
    else if(aChar == '<')
    {
      ended = true;
    }
    else if(started)
    {
      inData[index] = aChar;
      index++;
      inData[index] = '\0';
    }
  }

  if(started && ended)
  {
    // Convert the string to an integer
    int inInt = atoi(inData);

    Serial.println(inInt);

    // Get ready for the next time
    started = false;
    ended = false;

    index = 0;
    inData[index] = '\0';
  }
}
37  Using Arduino / Storage / Re: Arduino EEPROM Programmer: Burning a ROM image on: November 24, 2012, 02:02:54 pm
Answer found: Dave in the blog post clearly explains that he sent 64 bytes at once with 1 second between each 'burst'.

http://z80dave.blogspot.co.uk/2011/09/21-building-eeprom-programmer-part-2.html
38  Using Arduino / Storage / Re: Arduino EEPROM Programmer: Burning a ROM image on: November 24, 2012, 06:52:18 am
It seems to me that a writing cycle consists of 5 pulses (switching the control pins on and off). Would 5 ms be sufficient between sending each byte?
39  Using Arduino / Storage / Re: Arduino EEPROM Programmer: Burning a ROM image on: November 23, 2012, 11:15:52 pm
I'm planning to use Dave's (Legendmythe) sketch. He used a Linux script to send the hex file over serial. I want to use Max MSP, since it can read hex files and send them over serial very easily. However I'm not sure about the speed. There a module in Max which acts as a metronome (called 'metro'). The bytes are sent every time metro sends a trigger signal. The time is specified in milliseconds. How many bytes can I send per second?
40  Using Arduino / Microcontrollers / Re: Arduino Mega 1280 bootlader reinstall with an other Arduino on: November 20, 2012, 09:06:00 pm
Read the whole post... embarrassing. But basically this is the solution:

- wire the programmer and the Mega (or in this case the Freeduino Epic) like this:

Programmer       Mega
D10 (SS)            Reset
D11 (MOSI)          D51
D12 (MISO)          D50
D13 (SCK)           D52
Gnd                   Gnd
+5V                   +5V


- download the sketch from here: http://gammon.com.au/Arduino/Atmega_Board_Programmer.zip and upload it to the programmer Arduino

- set the Tools/Boards the target to Mega (1280 in my case)

- open the serial monitor, type 'g' and hit Enter

Taraaaaa! That's it! Special thanks to Nick Gammon for the excellent post and the sketch!
41  Using Arduino / Microcontrollers / Re: Arduino Mega 1280 bootlader reinstall with an other Arduino on: November 20, 2012, 05:40:55 pm
Success, thank you!
42  Using Arduino / Microcontrollers / Re: Arduino Mega 1280 bootlader reinstall with an other Arduino on: November 20, 2012, 05:37:57 pm
Tried, still get error:

avrdude: ser_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding



43  Using Arduino / Microcontrollers / Re: Arduino Mega 1280 bootlader reinstall with an other Arduino on: November 20, 2012, 03:42:00 pm
Silly me, I haven't set the Programmer to 'Arduino as ISP'. I set it then I got this error message:


avrdude: Version 5.11, compiled on Sep  2 2011 at 18:52:52
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "/Applications/Arduino 2.app/Contents/Resources/Java/hardware/tools/avr/etc/avrdude.conf"
         User configuration file is "/Users/alkopop79/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : /dev/tty.usbserial-A9007KZM
         Using Programmer              : stk500v1
         Overriding Baud Rate          : 19200
avrdude: Send: 0 [30]   [20]
avrdude: Send: 0 [30]   [20]
avrdude: Send: 0 [30]   [20]
avrdude: Recv: . [15]
avrdude: stk500_getsync(): not in sync: resp=0x15

avrdude done.  Thank you.


What am I doing wrong?
44  Using Arduino / Microcontrollers / Re: Arduino Mega 1280 bootlader reinstall with an other Arduino on: November 20, 2012, 03:39:45 pm
I followed the wiring described here Wiring for Mega2560 and similar but the IDE gives me this error:

avrdude: Version 5.11, compiled on Sep  2 2011 at 18:52:52
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "/Applications/Arduino 2.app/Contents/Resources/Java/hardware/tools/avr/etc/avrdude.conf"
         User configuration file is "/Users/alkopop79/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : usb
         Using Programmer              : stk500v2
avrdude: usbdev_open(): did not find any USB device "usb"


Needless to say, the Duemilanove has the 'Arduino ISP' sketch uploaded and then the board set to Mega 1280 in the IDE's menu. Any ideas?
45  Using Arduino / Microcontrollers / Arduino Mega 1280 bootlader reinstall with an other Arduino on: November 20, 2012, 03:11:59 pm
I have a Mega 1280 compatible Freeduino Epic. Since I cannot upload any sketches to it I need to reinstall the bootloader. I haven't found much info how to do that. Most Mega related articles describe how to use the Mega as a programmer, not as a target. I want to use a Duemilanove as a programmer. Any ideas would be appreciated!
Pages: 1 2 [3] 4 5 ... 13