Show Posts
Pages: [1] 2 3
1  Forum 2005-2010 (read only) / Troubleshooting / Floating Point Fail? on: September 16, 2009, 10:48:30 pm
Here's some code I wrote (working on a matrix library, gotta start somewhere).

I'm just testing my code with serial input, and apparently now 3.14 time 1 equals 150.84! Someone, please try my code, I have no clue what's wrong!
Code:
#include <math.h>

double matrixa = 3.14;
double matrixb;
double matrixc;
double matrixd;
double val = 0;
double holdVal;

void setup() {
  Serial.begin(300);
  matrixc = 3;
  matrixd = 6.47;
}

void loop() {
  if(Serial.available() > 0) {
    matrixb = Serial.read();
  }

  matrixmult();
  Serial.println(val);
  delay(1000);
}

void matrixmult() {
  holdVal = matrixa * matrixb;
  val = holdVal;//*(matrixc*matrixd);
}
2  Forum 2005-2010 (read only) / Troubleshooting / Re: Anyone using Arduino board with XBee shield? on: April 09, 2009, 05:25:21 pm
remove the module before uploading.
3  Forum 2005-2010 (read only) / Troubleshooting / RFID Tag reader on: April 11, 2009, 06:33:22 pm
I modified some code so that the Arduino will light an LED in the event of the proper RFID tag being presented. It doesn't work, and I can't fix it. The problem seems to be at the line :
Code:
if (bytesread == 10, code == tagOne)

Can anyone help?



Code:
char tagOne[12] = "0415ED3917";   // put the values for your tags here  
int rstPin = 2;
int ledPin = 13;
int val = 0;
char code[10];
int bytesread = 0;

void setup() {
  Serial.begin(2400);
  pinMode(rstPin, OUTPUT);
  pinMode(ledPin, OUTPUT);
  digitalWrite(2, LOW);
}

void loop() {
  // read in and parse serial data:

  if(Serial.available() > 0) {          // if data available from reader
    if((val = Serial.read()) == 10) {   // check for header
      bytesread = 0;
      while(bytesread<10) {              // read 10 digit code
        if( Serial.available() > 0) {
          val = Serial.read();
          if((val == 10)||(val == 13)) { // if header or stop bytes before the 10 digit reading
            break;                       // stop reading
          }
          code[bytesread] = val;         // add the digit          
          bytesread++;                   // ready to read next digit  
        }
      }
      if(bytesread == 10, code == tagOne) {              // if 10 digit read is complete
        digitalWrite(ledPin, HIGH);
        Serial.print(code);
      }
    }
  }
}
4  Forum 2005-2010 (read only) / Troubleshooting / Re: Serial Communication stops when battery powered on: May 17, 2009, 01:12:15 pm
Do you have decoupling caps?

If you start transmitting without them, the battery is unable to provide all of the current to power the radio and the Arduino.

Try adding caps, then see what happens.

Also, try using an external voltage regulator for the radio, and set it up like this:

+9v---100uF cap---Regulator---10uF cap---+5v
            |                     |            |
            |____________|_______|
                                  |
                                  GND
5  Forum 2005-2010 (read only) / Troubleshooting / Re: diecimila uploading sketches to mini pro on: May 02, 2009, 11:38:53 pm
You need to connect a capacitor inline between the DTR from the Diecimila and the Pro Mini.

Which version of the Pro Mini is it?

3.3V/8MHz or 5V/16MHz?
6  Forum 2005-2010 (read only) / Troubleshooting / Re: Ping/RFID Reader not working. on: May 02, 2009, 11:36:54 pm
Nevermind!

I fixed the error.

This is what the problem was:
Code:
 if(Serial.available() > 0) {
    myChar = tss.read();
  }

It should say:

Code:
 if(tss.available() > 0) {
    myChar = tss.read();
  }
7  Forum 2005-2010 (read only) / Troubleshooting / Ping/RFID Reader not working. on: May 02, 2009, 08:26:17 pm
I wrote some code for the TouchShield and Arduino to make a basic GUI that I'm calling pArduOS. For some reason, the RFID reader (Parallax) and the Ping)) won't report their data to the computer.

Code follows:

TouchShield Code
Code:
void setup() {
  Serial.begin(9600);
  background(0,0,0);
  stroke(255);
  text("pArduOS, Version .1",205,2);
  text("Written by Adam Aitoumeziane",150,10);
  text("Includes code samples from arduino.cc",95,18);
  fill(0,0,255);
  rect(0,0,50,50);
  text("Ping",12,22);
  fill(0,255,0);
  rect(0,75,50,50);
  text("RFID",12,97);

}

void loop() {
  gettouch();

  if(mouseX > 0 & mouseX < 50 & mouseY > 0 & mouseY < 50) {
    Serial.print('A');
  }

  if(mouseX > 0 & mouseX < 50 & mouseY > 75 & mouseY < 125) {
    Serial.print('B');
  }
}

Arduino Code
Code:
#include <AFSoftSerial.h>
#define RXPIN 3
#define TXPIN 2


int pingPin = 7;
char myChar;
int  val = 0;
char code[10];
int bytesread = 0;

AFSoftSerial tss = AFSoftSerial(RXPIN,TXPIN);


void setup() {
  tss.begin(9600);
  Serial.begin(2400); // RFID reader SOUT pin connected to Serial RX pin at 2400bps
  pinMode(4,OUTPUT);   // Set digital pin 2 as OUTPUT to connect it to the RFID /ENABLE pin
  digitalWrite(4, LOW);                  // Activate the RFID reader
}

void loop() {
  if(Serial.available() > 0) {
    myChar = tss.read();
  }


  if(myChar == 'A') {
    pingProg();
  }

  if(myChar == 'B') {
    rfidProg();
  }
}

int pingProg() {
  long duration, inches, cm;

  // The PING))) is triggered by a HIGH pulse of 2 or more microseconds.
  // We give a short LOW pulse beforehand to ensure a clean HIGH pulse.
  pinMode(pingPin, OUTPUT);
  digitalWrite(pingPin, LOW);
  delayMicroseconds(2);
  digitalWrite(pingPin, HIGH);
  delayMicroseconds(5);
  digitalWrite(pingPin, LOW);

  // The same pin is used to read the signal from the PING))): a HIGH
  // pulse whose duration is the time (in microseconds) from the sending
  // of the ping to the reception of its echo off of an object.
  pinMode(pingPin, INPUT);
  duration = pulseIn(pingPin, HIGH);

  // convert the time into a distance
  inches = microsecondsToInches(duration);
  cm = microsecondsToCentimeters(duration);

  Serial.print(inches);
  Serial.print("in, ");
  Serial.print(cm);
  Serial.print("cm");
  Serial.println();
  

  delay(100);
}

int rfidProg() {
  if(Serial.available() > 0) {          // if data available from reader
    if((val = Serial.read()) == 10) {   // check for header
      bytesread = 0;
      while(bytesread<10) {              // read 10 digit code
        if( Serial.available() > 0) {
          val = Serial.read();
          if((val == 10)||(val == 13)) { // if header or stop bytes before the 10 digit reading
            break;                       // stop reading
          }
          code[bytesread] = val;         // add the digit          
          bytesread++;                   // ready to read next digit  
        }
      }
      if(bytesread == 10) {              // if 10 digit read is complete
        Serial.print("TAG code is: ");   // possibly a good TAG
        Serial.println(code);            // print the TAG code
      }
      bytesread = 0;
      delay(500);                       // wait for a second
    }
  }
}

  long microsecondsToInches(long microseconds)
{
  // According to Parallax's datasheet for the PING))), there are
  // 73.746 microseconds per inch (i.e. sound travels at 1130 feet per
  // second).  This gives the distance travelled by the ping, outbound
  // and return, so we divide by 2 to get the distance of the obstacle.
  // See: http://www.parallax.com/dl/docs/prod/acc/28015-PING-v1.3.pdf
  return microseconds / 74 / 2;
}

long microsecondsToCentimeters(long microseconds)
{
  // The speed of sound is 340 m/s or 29 microseconds per centimeter.
  // The ping travels out and back, so to find the distance of the
  // object we take half of the distance travelled.
  return microseconds / 29 / 2;
}
8  Forum 2005-2010 (read only) / Troubleshooting / Re: trouble with GPS shield on: March 07, 2009, 11:34:52 am
Try going to Tools > Board > Arduino w/ Atmega328
9  Forum 2005-2010 (read only) / Development / DTR Line to FTDI Cable on: March 01, 2009, 12:09:48 pm
Which pin of an FTDI cable should I attach to the DTR line coming off of the RESET pin on the Arduino?

10  Forum 2005-2010 (read only) / Development / Re: Nuovo Board on: January 29, 2009, 06:13:31 pm
Wow! That is awesome.

Everywhere else I go, hams are nowhere to be seen.

Update for Nuovo:

In my original post, I forgot to mention two things.
1: Male headers on the bottom of the board for easy breadboarding. (Only the outermost row of pins have male headers)
2. Accelerometer built in to the board.
11  Forum 2005-2010 (read only) / Development / Re: Nuovo Board on: January 29, 2009, 05:22:39 pm
Wait.. your user name kg4wsv.

That's a ham radio call sign, right?

If it is, hey! I'm a ham, too!

Callsign: KE5OPX
12  Forum 2005-2010 (read only) / Development / Re: Nuovo Board on: January 29, 2009, 04:30:11 pm
Yeah, I took a  look at the Sanguino, and it's what inspired me to use the 644P. The major disadvantage of the Sanguino is the inability to connect shields, unless you hack it up. Also, to use the pins, you have to either buy the breakout board, which is really hard to use, or to use a breadboard, which just adds more complexity. The sanguino wasn't designed with shields in mind, it was designed fro use in the Reprap.
13  Forum 2005-2010 (read only) / Development / Nuovo Board on: January 29, 2009, 11:59:29 am
I have been sketching out an Arduino clone/spinoff and I really don't know how to go about making it.

My ideas were to utilize the ATmel 644P processor as the core, and add extra headers on the inside of the preexisting ones, kind of like the Illuminato.
Also, I wanted to have two different methods of communicating with the computer, so the board has a USB port and a bluetooth radio built in.
For power, I decided that a two pin adapter like the one on the Seeduino and a standard coax battery plug were good choices.
The main reason I wanted to make this board is the fact that the Arduino's memory is just too small.
The 644P affords 4x the EEPROM, Flash, and RAM for larger and more complex sketches. Also, its limited amount of ports and lack of a built-in wireless data transmission method to complement the USB port make it less versatile then I would like.

Again, I really don't know how I should try and develop my ideas into something good. Please, any help would be greatly appreciated.
14  Forum 2005-2010 (read only) / Development / RFIDShield on: January 29, 2009, 06:15:13 pm
Since I keep seeing people on YouTube using crappy hacked-together RFID readers with Arduino, and I need easy RFID access in my new project, I decided to make a shield that takes an Innovations ID-12 or ID-20 RFID reader and hooks it right into the necessary pins on the Arduino. The shield fully open-source, and under a Creative Commons Attribution-Share Alike 3.0 license. The EAGLE files for the board are at http://www.liquidware.org/view.php?id=94. Also at that link is a description of the circuit.

I'm sending the GERBER files for the board off to a board house next week.
15  Forum 2005-2010 (read only) / Interfacing / Re: XBee Serial on: March 05, 2009, 02:55:51 pm
Thanks!

But can XBee's handle 5V TTL serial signals?
Pages: [1] 2 3