Show Posts
Pages: 1 2 [3]
31  Using Arduino / Programming Questions / Morse Code Programming Help on: November 11, 2012, 06:14:48 am
So I'm new to arduino and done very basic things so far, such as blinking leds etc.

I'm trying to progress and want to do a morse code ir tx and ir rx.

So far I have built a morse code that outputs via led when read from the serial monitor. Here i used a book for the code. Here is the code;

Code:
int ledPin = 12;

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

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

 int dotDelay = 200;
 
 void setup()
 {
   pinMode(ledPin, 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 !=NULL)
     {
       flashDotOrDash(sequence);
       i++;
     }
     delay(dotDelay * 3);  //Gap between each letter
 }
 
 void flashDotOrDash(char dotOrDash)
  {
    digitalWrite(ledPin, HIGH);
    if (dotOrDash == '.')
    {
      delay(dotDelay);
    }
    else //must be a dash
    {
      delay(dotDelay * 3);
    }
    digitalWrite(ledPin, LOW);
    delay(dotDelay);  //Gap between flashes
  }


I have now wired up the ir tx and ir rx on the breadboard. See attached.

Can anyone help me implement the code to read input from the serial monitor (using ir tx) and receiving it in the serial monitor as output (using the ir rx). This need to be any text string.

I am a beginner with programming language as well.

Thank you in advance.

Moderator edit: Quote tags changed to code tags. (Nick Gammon)
32  Using Arduino / Installation & Troubleshooting / Re: Windows 7 does not recognise UNO on: October 21, 2012, 03:02:49 pm
Many thanks for your reply.

When I initially did this it would not install. I followed the folder path and found the files, rebooted and tried again. Finally it worked. It was strange how it did not appear until after the reboot.

Thanks again.
33  Using Arduino / Installation & Troubleshooting / Windows 7 does not recognise UNO on: October 21, 2012, 05:38:43 am
I'm new to Arduino.

I have a windows 7 machine 64-bit.

I've downloaded the Arduino software and extracted all files.

Firstly I cannot find the COM/LPT ports. When in device manager there is an unknown device (the UNO board). When I right click and update drivers, when I get down to the arduino directory there is no UNO.inf file. Only two folders.

Can anyone help?
Pages: 1 2 [3]