Show Posts
Pages: 1 [2] 3
16  Using Arduino / Programming Questions / Re: Serial Monitor Menu on: December 13, 2012, 06:41:21 am
Bump
17  Using Arduino / Programming Questions / Serial Monitor Menu on: December 12, 2012, 05:54:23 pm
Hi,

Before we go any further I am a beginner and still finding my feet.

Below is the code i have written to create a simple menu in the serial monitor where i want the user to make choices etc.

Firstly, the int's at the beginning...is this the best way to go when creating a menu or should i be using #define. As i'm a beginner i'm not even sure if this is te correct thing to do.

Secondly, now that i have printed all the text i need to, to the serial monitor, how do i write an if statement in the void loop that takes the user input from the serial monitor and takes them to where they want to be. How could i test this is working? Logically if they select option one I want to perhaps print something in the serial monitor to confirm they are where they want to be. I will get onto the actual conversions later.

I hope that makes sense.

Many thanks.

Code:
int menuoption1 = 1;
int menuoption2 = 2;
int menuoption3 = 3;
int menuoption4 = 4;
int menuoption5 = 5;
int menuoption6 = 6;
int menuoption7 = 7;
int menuoption8 = 8;
int menuoption9 = 9;
int menuoption10 = 10;
int menuoption11 = 11;
int menuoption12 = 12;

void setup() {
 //Initialize serial and wait for port to open:
  Serial.begin(9600);
   // prints text and menu options for user to select from
  Serial.println("Welcome to my Bin, Dec, Oct, Hex Converter");
  delay(2000);
  Serial.println(" ");
  Serial.println("Please select a number from the options available");
  delay(2000);
  Serial.println(" ");
  Serial.println("Main Menu");
  Serial.println("---------");
  delay(1000);
  Serial.println("1. 2's comp Binary to Hex,");
  delay(1000);
  Serial.println("2. 2's comp Binary to Octal,");
  delay(1000);
  Serial.println("3. 2's comp Binary to Decimal,");
  delay(1000);
  Serial.println("4. Octal to 2's comp Binary,");
  delay(1000);
  Serial.println("5. Octal to Hex,");
  delay(1000);
  Serial.println("6. Octal to Decimal,");
  delay(1000);
  Serial.println("7. Hex to 2's comp Binary,");
  delay(1000);
  Serial.println("8. Hex to Octal,");
  delay(1000);
  Serial.println("9. Hex to Decimal,");
  delay(1000);
  Serial.println("10. Decimal to 2's comp Binary,");
  delay(1000);
  Serial.println("11. Decimal to Hex,");
  delay(1000);
  Serial.println("12. Decimal to Octal.");
}

void loop() {
   
}
18  Using Arduino / Programming Questions / Re: Please Help-IR TX RX on: December 08, 2012, 04:24:43 am
Bump
19  Using Arduino / Programming Questions / Re: Please Help-IR TX RX on: December 07, 2012, 04:19:31 pm
Apologies. Ignore that last comment. Something has clicked. That is what it is doing now because it is receiving something from the IR TX phototransistor. The IR RX is always receiving from the IR TX, I proved this by blocking the signal and then I got no result.

Now I need to interpret the morse that is sent from the IR TX Arduino. Thanks for the link in your first post.

Another question is, can I not use the char letters from the ir transmitter code but instead of just showing the dots and dashes say something like ".-" = "a" and then print the string to the serial monitor.

A separate question I have found links on dits and dahs and the code to receive. Can I apply this to dots and dashes I used in the IR TX code. For example in the codes I have found they specify dits and dahs can I change them for dots and dashes or does it matter. The only reason I ask this is because I have not referenced dits and dahs on the IR TX code.

Many thanks once again.
20  Using Arduino / Programming Questions / Re: Please Help-IR TX RX on: December 07, 2012, 11:18:57 am
I meant from the ir rx.

No unfortunately it's not victory. I only want it to return Received if it receives an ir signal. At the moment I am not sending anything so I know it's incorrect.

Any other suggestions.

Many thanks
21  Using Arduino / Programming Questions / Re: Please Help-IR TX RX on: December 07, 2012, 07:59:27 am
Thanks for the response. On the receiever i am now using the following code (still not sure its right-especially the declare on value).

Code:
int pin = 8;
int value;
void setup()
{
  Serial.begin(9600);
  pinMode (pin, INPUT);
}


void loop()
{
  value = digitalRead(pin);
{  if (value == HIGH)
  {
    Serial.println("Recieved");
    delay(100);
  }
}
}

what i have found now is that if i take a wire from the breadboard and put it to 5v on the reciever the serial monitor goes mad with the text "Receieved". Would this mean i have wired up incorrectly?

the images on the original post show the hardware.

I was expecting to transmit and then if receieved at the ir rx i would get the text "received" in the serial monitor.

I am completely confused by this.

Thanks again
22  Using Arduino / Programming Questions / Please Help-IR TX RX on: December 07, 2012, 06:50:51 am
Hi,

I'm struggling with a project where I need to send a string from the serial monitor to an IR TX hooked up to an arduino, which is then sent to the IR RX (hooked up to a seperate arduino)

Attached below is images showing the hardware. I believe this is wired correctly, if not please inform me.

Below is the code for the transmitter. I must admit I am not a good prgrammer and have struggled to get to this point. I have read up on the code and sort of understand it.

Code:
int irtxPin = 9;

char* letters[] = {
  ".-", "-...", "-.-", "-..", ".", "..-.", "--.", "....", "..",     //Letters A-I
  ".---", "-.-", ".-..", "--", "-.", "---", ".--.", "--.-", ".-.",  //Letters J-R
  "...", "-", "..-", "...-", ".--", "-..-", "-.--", "--.."          //Letters S-Z 
 };

char* numbers[] ={
  "-----", ".----", "..---", "...--", "....-", ".....", "-....",
  "--...", "---..", "----." //Numbers 0-9
 };

 int dotDelay = 200;
 
 void setup()
 {
   pinMode(irtxPin, OUTPUT);
   Serial.begin(9600);  //Set the communications speed between the Arduino board and the USB 9600 baud
 }
 
 void loop()
 {
   char ch;
   if (Serial.available())  //Constantly checks to see if any letters have been sent over the USB Connection and if the letter needs to be processed
   
   {
     ch = Serial.read(); //Reads a single letter
     if (ch >= 'a' && ch <= 'z')
     {
       flashSequence(letters[ch - 'a']); //Flashes the LED to match the string that has been input
     }
     else if (ch >='A' && ch <= 'Z')
     {
       flashSequence(letters[ch - 'A']);
     }
     else if (ch >='0' && ch <= '9')
     {
       flashSequence(numbers[ch - '0']);
     }
     else if (ch == ' ')
     {
       delay(dotDelay * 4);
     }
   }
 }
 
 void flashSequence(char* sequence)
 {
     int i = 0;
     while (sequence[i] !=NULL)
     {
       flashDotOrDash(sequence[i]);
       i++;
     }
     delay(dotDelay * 3);  //Gap between each letter
 }
 
 void flashDotOrDash(char dotOrDash)
  {
    digitalWrite(irtxPin, HIGH);
    if (dotOrDash == '.')
    {
      delay(dotDelay);
    }
    else //must be a dash
    {
      delay(dotDelay * 3);
    }
    digitalWrite(irtxPin, LOW);
    delay(dotDelay);  //Gap between flashes
  }

The main issue i believe is the receiver. I have tried various tests but have got no where. Can anyone help how I can translate the morse back into a text string and output to the serial monitor.

Things to note are I am obviously using seperate serial cables. I have tried to test if i am even getting a signal (see code below-which i know is wrong because it wont compile)

Code:
int receiver = 8;

void setup()
{
  Serial.begin(9600);
  pinMode (receiver, INPUT);
}

void loop()
{
  digitalRead(receiver, LOW);
}
  if (receiver, HIGH)
  {
    Serial.println("Recieved");
    delay(100);
  }
}

I have spent weeks looking online and trying various things but it does not seem to be clicking. I really want to learn this but I may need a step by step guide (which I have looked for, but found nothing).

PLEASE HELP...

Any help is greatly appreciated as i need to hand a report in on this project to my college.

Cheers.
23  Using Arduino / Programming Questions / Re: Morse Code Programming Help on: November 12, 2012, 11:28:14 am
So where in the void loop would this go? Or are each of these functions seperate in terms of where they can be place in the code?
24  Using Arduino / Programming Questions / Re: Morse Code Programming Help on: November 11, 2012, 05:43:40 pm
I just posted at the same time you did.

To do this do I need to use digital.write/digital.read?
25  Using Arduino / Programming Questions / Re: Morse Code Programming Help on: November 11, 2012, 05:41:20 pm
I've just done a simple test by unplugging the infrared transmitter and putting text in serial monitor and got output. So clearly its not going via infrared.

How do I get it to do this?

Apologies for my lack of knowledge, as i say this is all new to me.
26  Using Arduino / Programming Questions / Re: Morse Code Programming Help on: November 11, 2012, 05:33:47 pm
Ok so ive had a go at modifying the code. See below.

Code:
int irtxPin = 12;
int irrxPin = 2;

char* letters[] = {
  ".-", "-...", "-.-", "-..", ".", "..-.", "--.", "....", "..",     //Letters A-I
  ".---", "-.-", ".-..", "--", "-.", "---", ".--.", "--.-", ".-.",  //Letters J-R
  "...", "-", "..-", "...-", ".--", "-..-", "-.--", "--.."          //Letters S-Z 
 };

char* numbers[] ={
  "-----", ".----", "..---", "...--", "....-", ".....", "-....",
  "--...", "---..", "----." //Numbers 0-9
 };

 
 void setup()
 {
   pinMode(irtxPin, INPUT);
   Serial.begin(9600);  //Set the communications speed between the Arduino board and the USB 9600 baud
   pinMode(irtxPin, OUTPUT);
 }
 
 void loop()
 {
   char ch;
   if (Serial.available())  //Constantly checks to see if any letters have been sent over the USB Connection and if the letter needs to be processed
   
   {
     ch = Serial.read(); //Reads a single letter
     if (ch >= 'a' && ch <= 'z')
     {
       Serial.print(letters[ch - 'a']); //Flashes the LED to match the string that has been input
     }
     else if (ch >='A' && ch <= 'Z')
     {
       Serial.print(letters[ch - 'A']);
     }
     else if (ch >='0' && ch <= '9')
     {
       Serial.print(numbers[ch - '0']);
     }
  }
}

I now get serial monitor output.

Does this now mean that it has travelled via infrared over the infrared transmitter to the infrared receiever or just purely reading the serial monitor input and the outputing this in the serial monitor?

Secondly, the output to serial monitor is in dots and dashes, how do i get this into readable text string.

Again many thanks for your help.

I have attached a photo showing how it is wired.
27  Using Arduino / Programming Questions / Re: Morse Code Programming Help on: November 11, 2012, 04:10:15 pm
I'm going to look at the code now I'm back at home.

I attached a picture in the first post to show how it is now wired.

The code I posted was when I had just wired one led to receive morse. So I'm trying to use this existing code to modify to do what I want now its wired differently.

I'm going to read some stuff on serial.print also.

Cheers
28  Using Arduino / Programming Questions / Re: Morse Code Programming Help on: November 11, 2012, 03:32:20 pm
Many thanks for your patience on this issue.

I don't have the money at the moment to use a separate arduino. So as the decision goes I will remove the delay calls.

I will definitely need your help implementing this decision if you can.

As I have the ir tx going to pin 13 and pin 9 (for pwm-do I need extra code). I havent referenced pin 9 in the code. The analogue (A0) to the ir receiver I'm assuming will need to be INT as well?

How do I then get output to the serial monitor. I have tried searching for help, but like I said I am a beginner in terms of programming language?

Again, many thanks.

29  Using Arduino / Programming Questions / Re: Morse Code Programming Help on: November 11, 2012, 10:00:51 am
The only problem with that code is it reads the serial monitor outputs as morse via the led. I want this to go from serial monitor to infrared transmitter across to the infrared receiver and then back out as text string in the serial monitor.

But I have very little idea how to code that.

Thanks for your reply.
30  Using Arduino / Programming Questions / Re: Morse Code Programming Help on: November 11, 2012, 06:35:23 am
I posted in the wrong section the first time and couldn't delete the original. Honest mistake.
Pages: 1 [2] 3