Show Posts
Pages: 1 2 [3] 4
31  Forum 2005-2010 (read only) / Interfacing / selecting audio signals on: May 20, 2009, 03:53:33 pm
Hi all,

I'm trying to build an interface for a radio that will allow the user to either speak (by pressing a PTT button) or send a tone generated by the arduino (although i'm hoping to use the AtTiny84 luminet version). So, my question is this...

I want to select either the microphone or the tone pin and connect it to the mic input of the radio. So far i've got a complicated solution using a transistor logic inverter to select either a mosfet allowing the mic to connect to the audio in or a mosfet to provide a path for the tone pin to the audio in. Will this work, and is there an easier (smaller?) solution to this?

Also, will i need any sort of op amp etc?

Many thanks in advance!

PS does anyone know the best way to generate a tone with the PWM pin?
32  Forum 2005-2010 (read only) / Interfacing / upload via IR on: February 03, 2009, 02:44:52 pm
Just a thought that occured to me... would it be possible to upload a sketch via IR? you would need a tx and rx on both the board and PC, and a power source on the board. Is the baud rate too fast (9600 i think?)?
33  Forum 2005-2010 (read only) / Interfacing / Re: Wiring a LM335 on: February 03, 2009, 12:51:46 pm
it seems that this sensor is used in a potential divider, so you would use the circuit at the bottom of page 4 labeled basic temperature sensor and connect the output to an arduino analog pin. You coiuld then read this value and turn that into a temperature.
34  Forum 2005-2010 (read only) / Interfacing / for loop decrementing on: February 01, 2009, 05:27:52 pm
when i use the following code it refuses to print anything over serial. i get "begin" but nthing else. What have i done wrong?

int rtc[4] = {
    1,2,3  };
  Serial.begin(9600);
  Serial.println("begin");  
  for (int i = 3; i <1; i--) {
    Serial.print(rtc);
    if (i < 0) {
      Serial.print(":");
    }

  }
}

it works if i change it to i++. Help!

35  Forum 2005-2010 (read only) / Interfacing / Re: Mini-SSC Protocol on: January 16, 2009, 02:14:19 pm
ok, so what its doing is actually loading the serial data into c everytime, then deciding what to do with it depending on whether serialcount is 0 or 1.

Thanks for clearing that up!
36  Forum 2005-2010 (read only) / Interfacing / Re: Mini-SSC Protocol on: January 16, 2009, 10:02:00 am
Hi

Thanks for your help so far! It seems to be working in as much as i get three bytes, and only if the first byte is 255! however when i get it to echo the Servo and Angle bytes back i get a 255 everytime. Am i doing something wrong here?

byte Servo = 0;
byte c = 0;
byte Angle = 0;
int SerialCount = 99;

void setup() {
Serial.begin(9600);
}

void loop() {




  if (Serial.available()) {
    c = Serial.read();
    if (c == 255) {
      SerialCount = 0;
    }
    else if ((c != 255) && (SerialCount == 0)) {
      Servo = Serial.read();
      SerialCount++;
    }
    else if (c != 255 && SerialCount == 1) {
      Angle = Serial.read();      
      SerialCount++;
      
      Serial.print(Servo);

      Serial.print(Angle);
    }
  }
}
37  Forum 2005-2010 (read only) / Interfacing / Re: Mini-SSC Protocol on: January 13, 2009, 03:37:43 pm
thanks macegr!

I think i remember seeing that you can use Serial.available() to give you how many bytes there are in the buffer, but i might be wrong. research!

Was this something you found reasonably easy to get reliable?
38  Forum 2005-2010 (read only) / Interfacing / Mini-SSC Protocol on: January 13, 2009, 12:56:52 pm
I would like to use the Motorshield to turn the arduino into a simple servo controller that can recieve serial commands from RoboRealm and move the servos.

Robo realm can output the Mini-Serial-Servo-Controller (Mini-SSC) protocol which looks really simple, it sends 3 bytes, 255 (Start Bit?) followed by the servo you want to control, then the angle you want it to go to.

I dont have any of my hardware here, so this is so far theoretical but does this code look like it'll accept the 3 bytes and act upon them?

thanks!

Quote

 
#include <ServoTimer1.h>

ServoTimer1 servoA;
ServoTimer1 servoB;

void setup() {
serial.begin(9600);

servoA.attach(9);
servoB.attach(10);


}


void loop() {
  
  if (Serial.available()) {
    byte c = Serial.read();
    if (c == '255') {
      byte Servo = Serial.read();
      byte Angle = Serial.read();
      if ( (Servo > 0) && (Servo < 3)) {
      ServoMove(Servo, Angle);
      }
    }
        
  
}

void ServoMove(byte S, byte A) {
    
  if (S == 1) {
      ServoA.write(A);
  }
  else
    if (S == 2) {
       ServoB.write(A);
    }
}



 
39  Forum 2005-2010 (read only) / Interfacing / Re: Serial Interface on: December 23, 2008, 12:57:04 pm
Hi, Dont want to hijack your thread but dont think this is worth a new one! im using some of this code (Thanks!!!) but cant get it to work. i've taken the section that takes the numerical input and does something with it, but as soon as i press a key it moves out of the function. can anyone see what ive done wrong?

thanks

Code:
int getNumber()
{
  static char buffer[] = "000";
  static int received = 0;
  while(!Serial.available());
  if (Serial.available())
  {
    char c = Serial.read();
    //Serial.println(c);
    while (received < 4) {
      if (c >= '0' or c <= '9')
      {
        Serial.print(c);
        buffer[received++] = c;
        if (buffer[received] == '\0')
        {
          Serial.println("");
          Serial.print("Total slots set to: ");
          Serial.println(buffer);
          return atoi(buffer);
          received = 0;
        }
      }
    }
  }
}
40  Forum 2005-2010 (read only) / Interfacing / Re: Split a number into 10s and units on: December 22, 2008, 09:53:38 am
right ok i understand now! your right, i was over complicating things! Thankyou for clarifying!
41  Forum 2005-2010 (read only) / Interfacing / Re: Split a number into 10s and units on: December 22, 2008, 08:31:03 am
ok, so this seems to be working! am i right in thinking that the modulo does the division, but only returns the whole number and ignores the decimal?

This is the code i've got now!

Code:
 if (hour > 9) {
    hourNibble10 = hour%10;
    hourNibble = hour - (hourNibble10 * 10);

  }

  if (hour < 9 ) {
    hourNibble10 = 0;
    hourNibble = hour;

  }

  if (minute > 9) {
    minNibble10 = minute%10;
    minNibble = minute - (minNibble10 * 10);

  }

  if (minute < 9 ) {
    minNibble10 = 0;
    minNibble = minute;
  }
42  Forum 2005-2010 (read only) / Interfacing / Re: Split a number into 10s and units on: December 22, 2008, 07:25:54 am
yeah i appreciate it! i can see how to get the tens, all im doing is dividing it by ten so with 12 i'd get 1.2 and becasue its not a float it ignores the .2 giving me just the 1. However it was the units that had me stumped! i shall research the modulo operator now! Thankyou!
43  Forum 2005-2010 (read only) / Interfacing / Split a number into 10s and units on: December 22, 2008, 06:54:25 am
Probably really simple but...

I need to get the individual number from a time so i can output a nibble to a BCD to 10 decoder. So, if the time was 12:30 i need to find the 10s of hrs, hrs, 10s of minutes and minutes, so 1, then 2, then 3, then 0.

Im getting the time from a ds1307, so i can get just the hrs and just the minutes, but cant split them up! any help gratefully recieved.

Dave
44  Forum 2005-2010 (read only) / Interfacing / Re: Getting input from sparkfun Keypad on: November 17, 2008, 12:47:25 pm
Hi,

sorry for the delay in answering but thanks for your replies. I've been trying to get that first code example to work, and after some tweaking i managed to get it to compile but i still cant get it to actually output anything. can you have a look and see what i might be doing wrong?

thanks

Quote

 
#include <keypad.h>
#include <LiquidCrystal.h>

LiquidCrystal lcd(11, 13, 2, 7, 8, 9, 10);
keypad kpd = keypad(4, 3);
unsigned long i;

unsigned long GetUnsignedVal()
{
#define ENTER_KEY '#'
  unsigned long val = 0;
  char  key[2];
  int key_int = 0;
  for (;smiley-wink
  {
    key[0] = kpd.get_key();
    key[1] = '\0';
    if ((key[0] >= '0') && (key[0] <= '9')) {

      key_int = atoi(key);

      val *= 10;
      val += key_int;
      lcd.clear();
      lcd.print(val);
    
    }

    if (key[0] == ENTER_KEY) {
      break;
    }
    return val;


  }

}



void setup() {
  kpd.init();

}


void loop() {
  i = GetUnsignedVal();
  lcd.clear();
  lcd.print(i);


}


 
45  Forum 2005-2010 (read only) / Interfacing / Re: Getting input from sparkfun Keypad on: November 09, 2008, 01:50:33 pm
Thanks, i'll try this out!
Pages: 1 2 [3] 4