Show Posts
Pages: 1 2 [3] 4 5
31  Using Arduino / Programming Questions / Re: Arduino ISP Bootload Not Working on: December 29, 2011, 01:49:07 pm
The original version of the second ISP sketch worked! You can find it here: http://mega-isp.googlecode.com/files/ArduinoISP.04.zip

Thank you so much Coding Badly and everyone who helped out! This is why I love arduino!

Informational Solidarity,

Will
32  Using Arduino / Programming Questions / Re: Arduino ISP Bootload Not Working on: December 29, 2011, 01:34:14 pm
I tried modifying both versions of the Arduino ISP sketch as you described and both gave me this error:

avrdude: stk500_getsync(): not in sync: resp=0x15


All my hardware and software specs are identical to those in the example you showed us, but i am not using an arduino UNO. Instead I am using a duemilanove.
33  Using Arduino / Programming Questions / Re: Arduino ISP Bootload Not Working on: December 28, 2011, 10:02:54 pm
Thanks codingbadly! Do I paste this code into the ISP sketch? If so, where?
34  Using Arduino / Programming Questions / Re: Arduino ISP Bootload Not Working on: December 28, 2011, 08:53:05 pm
ajoffscott-

Yes the firmware is on the arduino I am trying to use as an ISP. I have no oscilloscope but i have used this crystal successfully on this breadboard before. A 1megaohm resistor across the crystal resulted in the same error message.
35  Using Arduino / Programming Questions / Re: Arduino ISP Bootload Not Working on: December 28, 2011, 08:50:30 pm
Coding Badly- Thank you for the help! I tried the 120 ohm resistor between reset and 5v on the arduino and on the breadboard with and without the 10k pull up resistor but I am still getting the same error.

Botgeist- I am using version 022 of the arduino IDE
36  Using Arduino / Programming Questions / Re: Arduino ISP Bootload Not Working on: December 28, 2011, 08:13:47 pm
I am not using the UNO. I am using the duemilanove.
37  Using Arduino / Programming Questions / Re: Arduino ISP Bootload Not Working on: December 28, 2011, 08:12:44 pm
External 16 mhz crystal with the 22pf caps
38  Using Arduino / Programming Questions / Re: Arduino ISP Bootload Not Working on: December 28, 2011, 07:46:48 pm
How does one disable the auto reset?
39  Using Arduino / Programming Questions / Arduino ISP Bootload Not Working on: December 28, 2011, 06:46:42 pm
I am trying to burn the arduino bootloader onto a blank atmega 328p chip using my regular duemilanove arduino as the programmer. I have followed all of the steps in the official tutorial here: http://arduino.cc/en/Tutorial/ArduinoISP I am using the breadboard layout and have triple checked all the connections. Every time I go to burn the bootloader the rx and tx flash for a few seconds before an error message pops up that says:

avrdude: stk500_paged_write(): (a) protocol error, expect=0x14, resp=0x11
avrdude: stk500_cmd(): programmer is out of sync


Does anybody know what is happening? Has anyone else had this problem?

Thanks,
Will
40  Community / Exhibition / Gallery / Plantduino Greenhouse on: July 02, 2011, 01:48:53 pm
This is my Plantduino Greenhouse! It automatically senses moisture and controls watering. It also has the capability to control light and temperature.


Check out more at revoltlab.com
41  Using Arduino / Programming Questions / Re: Laser Tag Problems on: April 06, 2011, 06:02:19 pm
... and here is the final version of the code:

Code:
/*
* Giving Credit where Credit Is Due
*
* Portions of this code were derived from code posted in the Arduino forums by Paul Malmsten.
* You can find the original thread here: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1176098434
*
* The Audio portion of the code was derived from the Melody tutorial on the Arduino wiki
* You can find the original tutorial here: http://arduino.cc/en/Tutorial/Melody
*/

int sensorPin  = 2;      // Sensor pin 1
int senderPin  = 3;      // Infrared LED on Pin 3
int triggerPin = 4;      // Pushbutton Trigger on Pin 4
int speakerPin = 12;     // Positive Lead on the Piezo
int blinkPin   = 13;     // Positive Leg of the LED we will use to indicate signal is received

int startBit   = 2000;   // This pulse sets the threshold for a transmission start bit
int endBit     = 3000;   // This pulse sets the threshold for a transmission end bit
int one        = 1000;   // This pulse sets the threshold for a transmission that represents a 1
int zero       = 400;    // This pulse sets the threshold for a transmission that represents a 0
int trigger;             // This is used to hold the value of the trigger read;
boolean fired  = false;  // Boolean used to remember if the trigger has already been read.
int ret[2];              // Used to hold results from IR sensing.
int waitTime = 300;     // The amount of time to wait between pulses

int playerLine = 14;     // Any player ID >= this value is a referee, < this value is a player;
int myCode     = 1;      // This is your unique player code;
int myLevel    = 1;      // This is your starting level;
int maxShots   = 6;      // You can fire 6 safe shots;
int maxHits    = 6;      // After 6 hits you are dead;
int myShots    = 0;      // You can fire 6 safe shots;
int myHits     = 0;      // After 6 hits you are dead;

int maxLevel   = 9;      // You cannot be promoted past level 9;
int minLevel   = 0;      // You cannot be demoted past level 0

int refPromote = 0;      // The refCode for promotion;
int refDemote  = 1;      // The refCode for demotion;
int refReset   = 2;      // The refCode for ammo reset;
int refRevive  = 3;      // The refCode for revival;

int replySucc  = 14;     // the player code for Success;
int replyFail  = 15;     // the player code for Failed;

void setup() {
  pinMode(blinkPin, OUTPUT);
  pinMode(speakerPin, OUTPUT);
  pinMode(senderPin, OUTPUT);
  pinMode(triggerPin, INPUT);
  pinMode(sensorPin, INPUT);
  randomSeed(analogRead(0));
  for (int i = 1;i < 4;i++) {
    digitalWrite(blinkPin, HIGH);
    playTone(900*i, 200);
    digitalWrite(blinkPin, LOW);
    delay(200);
  }

  Serial.begin(9600);
  Serial.println("Ready: ");
}

void loop() {
  senseFire();
  senseIR();
 
  if (ret[0] != -1) {
    playTone(1000, 50);
    Serial.print("Who: ");
    Serial.print(ret[0]);
    Serial.print(" What: ");
    Serial.println(ret[1]);
    if (ret[0] >= playerLine) {
      if (ret[1] == refPromote) {
        // Promote
        if (myLevel < maxLevel) {
          Serial.println("PROMOTED!");
          myLevel++;
          playTone(900, 50);
          playTone(1800, 50);
          playTone(2700, 50);
        }
      } else if (ret[1] == refDemote) {
        // demote
        if (myLevel > minLevel) {
          Serial.println("DEMOTED!");
          myLevel--;
        }
          playTone(2700, 50);
          playTone(1800, 50);
          playTone(900, 50);
      } else if (ret[1] == refReset) {
        Serial.println("AMMO RESET!");
        myShots = maxShots;
        playTone(900, 50);
        playTone(450, 50);
        playTone(900, 50);
        playTone(450, 50);
        playTone(900, 50);
        playTone(450, 50);
      } else if (ret[1] == refRevive) {
        Serial.println("REVIVED!");
        myShots = 0;
        myHits = 0;
        myLevel = 1;
        playTone(900, 50);
        playTone(1800, 50);
        playTone(900, 50);
        playTone(1800, 50);
        playTone(900, 50);
        playTone(800, 50);
      }
    } else {
      if (ret[1] == replySucc) {
        playTone(9000, 50);
        playTone(450, 50);
        playTone(9000, 50);
        Serial.println("SUCCESS!");       
      } else if (ret[1] == replyFail) {
        playTone(450, 50);
        playTone(9000, 50);
        playTone(450, 50);
        Serial.println("FAILED!");       
      }
      if (ret[1] <= maxLevel && ret[1] >= myLevel && myHits <= maxHits) {
        Serial.println("HIT!");
        myHits++;
        playTone(9000, 50);
        playTone(900, 50);
        playTone(9000, 50);
        playTone(900, 50);
      }
    }
  }
}

void senseIR() {
  int who[4];
  int what[4];
  int end;
  if (pulseIn(sensorPin, LOW, 50) < startBit) {
    digitalWrite(blinkPin, LOW);
    ret[0] = -1;
    return;
  }
  digitalWrite(blinkPin, HIGH);
  who[0]   = pulseIn(sensorPin, LOW);
  who[1]   = pulseIn(sensorPin, LOW);
  who[2]   = pulseIn(sensorPin, LOW);
  who[3]   = pulseIn(sensorPin, LOW);
  what[0]  = pulseIn(sensorPin, LOW);
  what[1]  = pulseIn(sensorPin, LOW);
  what[2]  = pulseIn(sensorPin, LOW);
  what[3]  = pulseIn(sensorPin, LOW);
  end      = pulseIn(sensorPin, LOW);
  if (end <= endBit) {
    Serial.print(end);
    Serial.println(" : bad end bit");
    ret[0] = -1;
    return;
  }
  Serial.println("---who---");
  for(int i=0;i<=3;i++) {
    Serial.println(who[i]);
    if(who[i] > one) {
      who[i] = 1;
    } else if (who[i] > zero) {
      who[i] = 0;
    } else {
      // Since the data is neither zero or one, we have an error
      Serial.println("unknown player");
      ret[0] = -1;
      return;
    }
  }
  ret[0]=convert(who);
  Serial.println(ret[0]);

  Serial.println("---what---");
  for(int i=0;i<=3;i++) {
    Serial.println(what[i]);
    if(what[i] > one) {
      what[i] = 1;
    } else if (what[i] > zero) {
      what[i] = 0;
    } else {
      // Since the data is neither zero or one, we have an error
      Serial.println("unknown action");
      ret[0] = -1;
      return;
    }
  }
  ret[1]=convert(what);
  Serial.println(ret[1]);
  return;
}

void playTone(int tone, int duration) {
  for (long i = 0; i < duration * 1000L; i += tone * 2) {
    digitalWrite(speakerPin, HIGH);
    delayMicroseconds(tone);
    digitalWrite(speakerPin, LOW);
    delayMicroseconds(tone);
  }
}

int convert(int bits[]) {
  int result = 0;
  int seed   = 1;
  for(int i=3;i>=0;i--) {
    if(bits[i] == 1) {
      result += seed;
    }
    seed = seed * 2;
  }
  return result;
}

void senseFire() {
  trigger = digitalRead(triggerPin);
  if (trigger == LOW && fired == false) {
    Serial.println("Button Pressed");
    fired = true;
    myShots++;
    if (myHits <= maxHits && myShots > maxShots && random(1,20) <= myShots) {
      Serial.println("SELF DESTRUCT");
      selfDestruct();
    } else if (myHits <= maxHits) {
      Serial.print("Firing Shot : ");
      Serial.println(myShots);
      fireShot(myCode, myLevel);
    }
  } else if (trigger == HIGH) {
    if (fired == true) {
      Serial.println("Button Released");
    }
    // reset the fired variable
    fired = false;
  }
}

void fireShot(int player, int level) {
  int encoded[8];
  digitalWrite(blinkPin, HIGH);
  for (int i=0; i<4; i++) {
    encoded[i] = player>>i & B1;   //encode data as '1' or '0'
  }
  for (int i=4; i<8; i++) {
    encoded[i] = level>>i & B1;
  }
  // send startbit
  oscillationWrite(senderPin, startBit);
  // send separation bit
  digitalWrite(senderPin, HIGH);
  delayMicroseconds(waitTime);
  // send the whole string of data
  for (int i=7; i>=0; i--) {
    if (encoded[i] == 0) {
      oscillationWrite(senderPin, zero);
    } else {
      oscillationWrite(senderPin, one);
    }
    // send separation bit
    digitalWrite(senderPin, HIGH);
    delayMicroseconds(waitTime);
  }
  oscillationWrite(senderPin, endBit);
  playTone(100, 5);
  digitalWrite(blinkPin, LOW);
}

void oscillationWrite(int pin, int time) {
  for(int i = 0; i <= time/26; i++) {
    digitalWrite(pin, HIGH);
    delayMicroseconds(13);
    digitalWrite(pin, LOW);
    delayMicroseconds(13);
  }
}

void selfDestruct() {
  myHits  = maxHits+1;
  playTone(1000, 250);
  playTone(750, 250);
  playTone(500, 250);
  playTone(250, 250);
}

This code tracks trigger pulls but has lost its ability to sense IR pulses. The comments on the original tutorial are closed so the Arduino forums are my last hope. Any idea what is stopping the final code from sensing IR pulses?
42  Using Arduino / Programming Questions / Laser Tag Problems on: April 06, 2011, 06:00:29 pm
I am trying to follow this tutorial: http://aterribleidea.com/2009/02/25/building-an-arduino-based-laser-tag-game/ on making an arduino laser tag system. The tutorial is great and even goes step by step through the code. The first version of the code works fine and registers incoming Infrared signals perfectly. The final version of the code tracks trigger pulls correctly, but does not sense IR pulses.
Here is the first version of the code:
Code:
/*

*/

int sensorPin  = 2;      // Sensor pin 1
int speakerPin = 12;     // Positive Lead on the Piezo
int blinkPin   = 13;     // Positive Leg of the LED we will use to indicate signal is received

int startBit   = 2000;   // This pulse sets the threshold for a transmission start bit
int one        = 1000;   // This pulse sets the threshold for a transmission that represents a 1
int zero       = 400;    // This pulse sets the threshold for a transmission that represents a 0

int ret[2];              // Used to hold results from IR sensing.

int playerLine = 14;     // Any player ID >= this value is a referee, < this value is a player;
int myCode     = 1;      // This is your unique player code;
int myLevel    = 1;      // This is your starting level;
int maxShots   = 6;      // You can fire 6 safe shots;
int maxHits    = 6;      // After 6 hits you are dead;
int myShots   = maxShots;// You can fire 6 safe shots;
int myHits    = maxHits; // After 6 hits you are dead;

int maxLevel   = 9;      // You cannot be promoted past level 9;
int minLevel   = 0;      // You cannot be demoted past level 0

int refPromote = 0;      // The refCode for promotion;
int refDemote  = 1;      // The refCode for demotion;
int refReset   = 2;      // The refCode for ammo reset;
int refRevive  = 3;      // The refCode for revival;

int replySucc  = 14;     // the player code for Success;
int replyFail  = 15;     // the player code for Failed;

void setup() {
  pinMode(blinkPin, OUTPUT);
  pinMode(speakerPin, OUTPUT);
  pinMode(sensorPin, INPUT);

  for (int i = 1;i < 4;i++) {
    digitalWrite(blinkPin, HIGH);
    playTone(900*i, 200);
    digitalWrite(blinkPin, LOW);
    delay(200);
  }

  Serial.begin(9600);
  Serial.println("Ready: ");
}

void loop() {
  senseIR();
  
  if (ret[0] != -1) {
    playTone(1000, 50);
    Serial.print("Who: ");
    Serial.print(ret[0]);
    Serial.print(" What: ");
    Serial.println(ret[1]);
    if (ret[0] >= playerLine) {
      if (ret[1] == refPromote) {
        // Promote
        if (myLevel < maxLevel) {
          Serial.println("PROMOTED!");
          myLevel++;
          playTone(900, 50);
          playTone(1800, 50);
          playTone(2700, 50);
        }
      } else if (ret[1] == refDemote) {
        // demote
        if (myLevel > minLevel) {
          Serial.println("DEMOTED!");
          myLevel--;
        }
          playTone(2700, 50);
          playTone(1800, 50);
          playTone(900, 50);
      } else if (ret[1] == refReset) {
        Serial.println("AMMO RESET!");
        myShots = maxShots;
        playTone(900, 50);
        playTone(450, 50);
        playTone(900, 50);
        playTone(450, 50);
        playTone(900, 50);
        playTone(450, 50);
      } else if (ret[1] == refRevive) {
        Serial.println("REVIVED!");
        myShots = maxShots;
        myHits = maxHits;
        myLevel = 1;
        playTone(900, 50);
        playTone(1800, 50);
        playTone(900, 50);
        playTone(1800, 50);
        playTone(900, 50);
        playTone(800, 50);
      }
    } else {
      if (ret[1] == replySucc) {
        playTone(9000, 50);
        playTone(450, 50);
        playTone(9000, 50);
        Serial.println("SUCCESS!");        
      } else if (ret[1] == replyFail) {
        playTone(450, 50);
        playTone(9000, 50);
        playTone(450, 50);
        Serial.println("FAILED!");        
      }
      if (ret[1] <= maxLevel && ret[1] >= myLevel && myHits > 0) {
        Serial.println("HIT!");
        myHits--;
        playTone(9000, 50);
        playTone(900, 50);
        playTone(9000, 50);
        playTone(900, 50);
      }
    }
  }
}

void senseIR() {
  int who[4];
  int what[4];
  while(pulseIn(sensorPin, LOW) < startBit) {
    digitalWrite(blinkPin, LOW);
  }
  digitalWrite(blinkPin, HIGH);
  who[0]   = pulseIn(sensorPin, LOW);
  who[1]   = pulseIn(sensorPin, LOW);
  who[2]   = pulseIn(sensorPin, LOW);
  who[3]   = pulseIn(sensorPin, LOW);
  what[0]  = pulseIn(sensorPin, LOW);
  what[1]  = pulseIn(sensorPin, LOW);
  what[2]  = pulseIn(sensorPin, LOW);
  what[3]  = pulseIn(sensorPin, LOW);

  Serial.println("---who---");
  for(int i=0;i<=3;i++) {
    Serial.println(who[i]);
    if(who[i] > one) {
      who[i] = 1;
    } else if (who[i] > zero) {
      who[i] = 0;
    } else {
      // Since the data is neither zero or one, we have an error
      Serial.println("unknown player");
      ret[0] = -1;
      return;
    }
  }
  ret[0]=convert(who);
  Serial.println(ret[0]);

  Serial.println("---what---");
  for(int i=0;i<=3;i++) {
    Serial.println(what[i]);
    if(what[i] > one) {
      what[i] = 1;
    } else if (what[i] > zero) {
      what[i] = 0;
    } else {
      // Since the data is neither zero or one, we have an error
      Serial.println("unknown action");
      ret[0] = -1;
      return;
    }
  }
  ret[1]=convert(what);
  Serial.println(ret[1]);
  return;
}


void playTone(int tone, int duration) {
  for (long i = 0; i < duration * 1000L; i += tone * 2) {
    digitalWrite(speakerPin, HIGH);
    delayMicroseconds(tone);
    digitalWrite(speakerPin, LOW);
    delayMicroseconds(tone);
  }
}

int convert(int bits[]) {
  int result = 0;
  int seed   = 1;
  for(int i=3;i>=0;i--) {
    if(bits[i] == 1) {
      result += seed;
    }
    seed = seed * 2;
  }
  return result;
}
43  Community / Exhibition / Gallery / Re: Make Your Own Arduino on: March 28, 2011, 10:48:49 pm
Very cool CrossRoads! I might add a step at the beginning of the perfduino walk through explaining how to use a raw chip!
44  Community / Exhibition / Gallery / Re: Make Your Own Arduino on: March 28, 2011, 04:34:27 pm
Thanks fkeel!

Boz, very nice board. It looks perfect for breadboards! Is there any kind of pin label?
45  Community / Exhibition / Gallery / Re: Make Your Own Arduino on: March 27, 2011, 12:00:41 pm
You are most welcome! Glad to help the spread of knowledge in any way I can. Thanks for the compliment. You are right about the cost of arduino boards. I actually had to make this one in order to continue developing the Revolt Lab laser tag training system ( http://revoltlab.com/projects/laser-tag/ ). The parts sourcing article should be up on the site Monday or Tuesday. After that is up, we will also be expanding the "Supplies" section of the Knowledge page.
Pages: 1 2 [3] 4 5