Show Posts
Pages: 1 [2] 3 4 ... 7
16  Using Arduino / Programming Questions / Re: binary to text char. on: February 23, 2014, 06:19:32 am
char msg[]="hello";
char binary[512];
char* charbin[64];
char temp[]="00000000";

void setup() {
  Serial.begin(9600);         // open serial port at 9600 baud
}

and those are the declarations and setup
17  Using Arduino / Programming Questions / Re: binary to text char. on: February 23, 2014, 06:12:37 am
Code:
void loop() {
  for(int i=0; i<5; i++){
    byte c = msg[i];   // read one character
    for(int i=0; i<8; i++) { 
      if ((c%2)==0){
        binary[i]='0';      // print the least significant bit
        c /= 2;
      }
      else if((c%2)==1){      // move to next significant bit
        binary[i]='1';
        c /= 2; 
      }
    }
  }
  for (int i=0; i<64; i++){
   for (int a=0; a<8; a++){
    temp[a]=binary[a];
   }
  charbin[i] = temp;
  }
  Serial.println(charbin);
  delay(2000);
}
18  Using Arduino / Programming Questions / Re: binary to text char. on: February 23, 2014, 06:10:50 am
i have it outside of the loop.

 i want to print out everything after it is done.

you have something else in your mind ?
19  Using Arduino / Programming Questions / Re: binary to text char. on: February 23, 2014, 05:17:19 am
 i get this compilation error : call of overloaded 'println(char*[64])' is ambiguous.

can any one tell me why i get this compilation error?
20  Using Arduino / Programming Questions / Re: binary to text char. on: February 22, 2014, 09:25:52 pm
well everything is for educational reason only.

i would like to brake a string of characters to zeros and ones and then reconstract from the zeros and ones the initial string.

my first thought is to brake every character to it's ASCII code binary by using one FOR LOOP
Code:
for(int i=0; i<5; i++){
    byte c = msg[i];   // read one character
    for(int i=0; i<8; i++) { 
      if ((c%2)==0){        //if it is 0,
        binary[i]='0';      // right it to the binary[i]
        c /= 2;                  // move to next significant bit
      }
      else if((c%2)==1){     // if it is 1,
        binary[i]='1';           //right it to binary[i]
        c /= 2;                     // move to next significant bit
      }
    }
  }

and until this point everything works great.
if i try a Serial.print(binary) i get a sting of 40 zeros and ones

my problem starts when i try to break every 8 bits to an Array of strings. ( i am thinking that it would be nice to have them organised in on string( for example "01010101","10101010")

and my problem startson the reconstruction. i have this loop
Code:
for (int i=0; i<64; i++){         
   for (int a=0; a<8; a++){
    temp[a]=binary[a];   // put every bit in order inside temp
   }
  charbin[i] = temp; / write temp in to charbin[i]
  }

but i get this compilation error : call of overloaded 'println(char*[64])' is ambiguous.

am i thinking correct ?

wouldn't this be the way to do it ?

if not what could i do to break 64 characters in to zeros and ones and how can i reconstruct from zeros and ones  the same sting of 64 chars ?


21  Using Arduino / Programming Questions / binary to text char. on: February 22, 2014, 05:37:45 pm
Hello to the community

here is my code
Code:
char msg[]="hello";
char binary[512];
char* charbin[64];
char temp[]="00000000";

void setup() {
  Serial.begin(9600);         // open serial port at 9600 baud
}

void loop() {
  for(int i=0; i<5; i++){
    byte c = msg[i];   // read one character
    for(int i=0; i<8; i++) {  
      if ((c%2)==0){
        binary[i]='0';      // print the least significant bit
        c /= 2;
      }
      else if((c%2)==1){      // move to next significant bit
        binary[i]='1';
        c /= 2;  
      }
    }
  }
  for (int i=0; i<64; i++){
   for (int a=0; a<8; a++){
    temp[a]=binary[a];
   }
  charbin[i] = temp;
  }
  Serial.println(charbin);
  delay(2000);
}


all i want to do i break the sting of 64 chars to binary ( so 8*64=512 right?????? 0 and 1 );

and then reconstract the original sting again.

msg="hello" value in my code is for test only.

i don't understand what is wrong actualy with my code.
i get this conpilation error but i don't understand why.

any help?
22  Using Arduino / Programming Questions / Re: 4-ds18b20 temp sensors / 20x4 LCD / Uno ??? on: February 18, 2014, 10:11:01 pm
can you send the datasheet of the lcd?

one wire 20x4 lcd ???????????
23  Using Arduino / Programming Questions / Re: PWM with potentiometer variable? on: February 18, 2014, 09:48:02 pm
why don't you try this :http://arduino.cc/en/Tutorial/ReadAnalogVoltage#.UwQdCPl_t8E

or this first  :http://www.arduino.cc/en/Tutorial/Potentiometer#.UwQcp_l_t8E
24  Using Arduino / Programming Questions / Re: conbination of two codes ! (4x4 keypad to 16x2 lcd texter), morse EnDecoder ! on: February 18, 2014, 09:31:44 pm
and it can be done with the morse EnDecoder library,

here is the code :
http://pastebin.com/nUQEUpwf

there is somthing about the delay.

if take the
delay(preventholddelay); //delay a little to prevent continuous cycling

it will play the morse code as long as you keep the btn pressed.

now this is not right but ..... at least now i now exactly where the problem is.


does enyone have any idea on how to fix that ?
25  Using Arduino / Programming Questions / Re: conbination of two codes ! (4x4 keypad to 16x2 lcd texter), morse EnDecoder ! on: February 17, 2014, 06:34:22 pm
Finaly one step is done.

but sadly without this beautifull library.

this is the code i've been using : http://pastebin.com/gqCbvbQe

and attached, is the hardware setup.


now next step is to decode the morse code from a mic.

26  Using Arduino / Programming Questions / Re: conbination of two codes ! (4x4 keypad to 16x2 lcd texter), morse EnDecoder ! on: February 17, 2014, 08:27:11 am
well i thing that it has to do with some kind of timer.

those are the conclusion i came up so far.

first of all this is the code i use ( it is the last function is the texter code )

Code:
void outputserial(){ //output message and display remaining characters to serial console
morseInput.setspeed(13);
morseOutput.setspeed(13);
lastTransmissionTime = (long)millis();
if (morseOutput.available()){
for (int i=0; i<(positionintypedtext); i++){
morseDecoder morseInput(morseInPin, MORSE_KEYER, MORSE_ACTIVE_LOW);
morseEncoder morseOutput(morseOutPin);
// Variables dealing with formatting the output somewhat
// by inserting CR's (carriage returns)
Serial.println();
Serial.print(i);
Serial.print(')' );
Serial.print(lastTransmissionTime);
Serial.print(' ');
currentTime = (long)millis();
Serial.print(currentTime);
Serial.print(' ');
// Needs to call these once per loop
// SEND MORSE (OUTPUT)
// Encode and send text received from the serial port (serial monitor)
// Get character from serial and send as Morse code
char sendMorse = typedtext[i];
morseOutput.write(sendMorse);
Serial.print(' ');
Serial.print(sendMorse);
// Not strictly needed, but used to get morseSignalString before it is destroyed
// (E.g. for morse training purposes)
morseOutput.encode();
// Also write sent character + Morse code to serial port/monitor
Serial.write(' ');
Serial.write(sendMorse);
Serial.write(morseOutput.morseSignalString);
}
// RECEIVE MORSE (INPUT)
// If a character is decoded from the input, write it to serial port
}
delay(preventholddelay); //delay a little to prevent continuous cycling
}


and this is what i take as results in serial window ( for a random text i entered ) :
0)6413 6413 E E.
1)6413 6414 N N-.
2)6413 6415 J J.—
3)6413 6418 P P.–.
4)6413 6440 G G–.
5)6413 6463 A A.-
6)6413 6483 P P.–.
7)6413 6506 J J.—
8)6413 6530 D D-..
9)6413 6551 J J.—
10)6413 6575 T T-
11)6413 6596 M M–
12)6413 6618 D D-..
13)6413 6640 P P.–.
14)6413 6665 M M–
15)6413 6686 A A.-
16)6413 6708 J J.—
17)6413 6732 T T-
18)6413 6753 J J.—
19)6413 6776 D D-..
20)6413 6800 T T-
21)6413 6820 M M–
22)6413 6842 D D-..
23)6413 6865 T T-
24)6413 6886 W W.–
25)6413 6908 M M–
26)6413 6931 J J.—
27)6413 6955 T T-

first of all, i see that there is a ~ 22 milisecconds deference between each time it passes through the for loop, except the three first ones that passes in just 1 millisecond.

if (morseOutput.available()
this works, while if this didn’t work it wouldn’t go through the for loop and i wouldn’t get the print outs i have sent you above. smiley-grin !
i changed pinout to 2, just iin case and it was messing with the pin 13 and the outpouts to the Serial window. nop that wasn’t. smiley-grin !
i am preaty sure that the communication with the library is really ok while with out it
Serial.write(morseOutput.morseSignalString); couldn’t get the print outs with the char and the morse code right next. smiley-grin !
but if the library connection is ok,
morseOutput.write(sendMorse);
witch everytime it passes through the for loop is the correct character, SO EVEN THIS WORKS smiley-grin !
morseOutput.encode();
when we get to this guy, ( oh my head is a mess right now, and i am still loughing ) it seems like it works for some milliseconts.
my grandma used to say ” it is at a corner, and it is smilling at you ” everytime i was looking for something.
it is really close but i can not figure out why it is not working.
i don’t want to mess with the libraries. i am preaty sure that the libraries are ok.
if you have any sudgestions . any of some sort ….. more than welcome.
27  Using Arduino / Programming Questions / Re: conbination of two codes ! (4x4 keypad to 16x2 lcd texter), morse EnDecoder ! on: February 15, 2014, 05:49:54 am
well it worked parcialy ok and i have bips

here is the code

Code:
void outputserial(){ //output message and display remaining characters to serial console
  for (int i=0; i<(positionintypedtext); i++){
  #include <pgmspace.h>
#include <MorseEnDecoder.h>

// Pin mappings
const byte morseInPin = 2;     
const byte morseOutPin = 13;
// Instantiate Morse objects
morseDecoder morseInput(morseInPin, MORSE_KEYER, MORSE_ACTIVE_LOW);
morseEncoder morseOutput(morseOutPin);

// Variables dealing with formatting the output somewhat
// by inserting CR's (carriage returns)
long lastTransmissionTime;
long currentTime;
boolean transmissionEnded = true; // Flag to mark old transmission is finished

// Minimum transmission pause time to insert carriage returns (CR)
// Adjust depending on Morse speed. IE 13 wpm = 646 ms between words (no CR).
const long transmissionPaused   = 1000; // Suitable for 13 wpm?
 
  // Setting Morse speed in wpm - words per minute
  // If not set, 13 wpm is default anyway
  morseInput.setspeed(13);
  morseOutput.setspeed(13);
 
  lastTransmissionTime = (long)millis();
 
    Serial.println();
    Serial.print(i);
 
  currentTime = (long)millis();
 
  // Needs to call these once per loop
  morseInput.decode();
  morseOutput.encode();

  // SEND MORSE (OUTPUT)
  // Encode and send text received from the serial port (serial monitor)
 
    // Get character from serial and send as Morse code
    char sendMorse = typedtext[i];
    morseOutput.write(sendMorse);
    Serial.print(' ');
    Serial.print(sendMorse);
    // Not strictly needed, but used to get morseSignalString before it is destroyed
    // (E.g. for morse training purposes)
    morseOutput.encode();

    // Also write sent character + Morse code to serial port/monitor
    Serial.write(' ');
    Serial.write(sendMorse);
    Serial.write(morseOutput.morseSignalString);
 


  // RECEIVE MORSE (INPUT)
  // If a character is decoded from the input, write it to serial port
  if (morseInput.available())
  {
    // Get decoded Morse code character and write it to serial port/monitor
    char receivedMorse = morseInput.read();
    Serial.print(receivedMorse);
   
    // A little error checking   
    if (receivedMorse == '#') Serial.println("< ERROR:too many morse signals! >");
  }


  // Local Morse code feedback from input if not sending Morse simultaneously
  if (morseOutput.available()) digitalWrite(morseOutPin, morseInput.morseSignalState);


  // Check if ongoing transmission (not yet transmission pause)
  if (!morseOutput.available() || morseInput.morseSignalState == true)
  {
    // reset last transmission timer and flag
    lastTransmissionTime = currentTime;
    transmissionEnded = false;
  }

  // Format output with carriage returns after a transmission pause
  if ((currentTime - lastTransmissionTime) > transmissionPaused)
  {
    if (transmissionEnded == false)
    {
      // Separate the transmissions somewhat in the serial monitor with CR's
      for (int cr=0; cr<2; cr++) Serial.println("");  // some carriage returns..
     
      // Finally set the flag to prevent continous carriage returns
      transmissionEnded = true;
    }
  }
  }
   //delay a little to prevent continuous cycling
}

morse decode is just fine here is an utput of a random text
0 E E.
1 N N-.
2 K K-.-
3 T T-
4 W W.--
5 M M--
6 D D-..
0 E E.
1 N N-.
2 K K-.-
3 T T-
4 W W.--
5 M M--
6 D D-..
7 J J.---
8 U U..-
9 W W.--
10 M M--
11 D D-..
12 A A.-
13 K K-.-
14 H H....
15 Q Q--.-
16 B B-...
17 D D-..
18 N N-.
19 X X-..-
20 U U..-
21 J J.---
22 M M--
23 E E.
24 B B-...
25 Z Z--..
26 R R.-.

but everything works so fast, like 1000 words per minute.

any one has any idea ?
28  Using Arduino / Programming Questions / Re: conbination of two codes ! (4x4 keypad to 16x2 lcd texter), morse EnDecoder ! on: February 15, 2014, 04:46:33 am
i included everything from the morse EnDecoder code ( that works realy fine with my setup) inside the  outputserial() Function

here is the code
Code:
void outputserial(){ //output message and display remaining characters to serial console
  #include <avr/pgmspace.h>
#include <MorseEnDecoder.h>

// Pin mappings
const byte morseInPin = 2;     
const byte morseOutPin = 13;
// Instantiate Morse objects
morseDecoder morseInput(morseInPin, MORSE_KEYER, MORSE_ACTIVE_LOW);
morseEncoder morseOutput(morseOutPin);

// Variables dealing with formatting the output somewhat
// by inserting CR's (carriage returns)
long lastTransmissionTime;
long currentTime;
boolean transmissionEnded = true; // Flag to mark old transmission is finished

// Minimum transmission pause time to insert carriage returns (CR)
// Adjust depending on Morse speed. IE 13 wpm = 646 ms between words (no CR).
const long transmissionPaused   = 1000; // Suitable for 13 wpm?
 
  // Setting Morse speed in wpm - words per minute
  // If not set, 13 wpm is default anyway
  morseInput.setspeed(13);
  morseOutput.setspeed(13);
 
  lastTransmissionTime = (long)millis();
 
  for (int i=0; i<(positionintypedtext); i++){
  Serial.print(i);
 
  currentTime = (long)millis();
 
  // Needs to call these once per loop
  morseInput.decode();
  morseOutput.encode();

  // SEND MORSE (OUTPUT)
  // Encode and send text received from the serial port (serial monitor)
 
    // Get character from serial and send as Morse code
    char sendMorse = typedtext[i];
    morseOutput.write(sendMorse);
    Serial.print(' ');
    Serial.print(sendMorse);
    // Not strictly needed, but used to get morseSignalString before it is destroyed
    // (E.g. for morse training purposes)
    morseOutput.encode();

    // Also write sent character + Morse code to serial port/monitor
    Serial.write(' ');
    Serial.write(sendMorse);
    Serial.write(morseOutput.morseSignalString);
 


  // RECEIVE MORSE (INPUT)
  // If a character is decoded from the input, write it to serial port
  if (morseInput.available())
  {
    // Get decoded Morse code character and write it to serial port/monitor
    char receivedMorse = morseInput.read();
    Serial.print(receivedMorse);
   
    // A little error checking   
    if (receivedMorse == '#') Serial.println("< ERROR:too many morse signals! >");
  }


  // Local Morse code feedback from input if not sending Morse simultaneously
  if (morseOutput.available()) digitalWrite(morseOutPin, morseInput.morseSignalState);


  // Check if ongoing transmission (not yet transmission pause)
  if (!morseOutput.available() || morseInput.morseSignalState == true)
  {
    // reset last transmission timer and flag
    lastTransmissionTime = currentTime;
    transmissionEnded = false;
  }

  // Format output with carriage returns after a transmission pause
  if ((currentTime - lastTransmissionTime) > transmissionPaused)
  {
    if (transmissionEnded == false)
    {
      // Separate the transmissions somewhat in the serial monitor with CR's
      for (int cr=0; cr<2; cr++) Serial.println("");  // some carriage returns..
     
      // Finally set the flag to prevent continous carriage returns
      transmissionEnded = true;
    }
  }
  Serial.println();
}
  delay(preventholddelay); //delay a little to prevent continuous cycling
}

i inputed a random text "BKMDBZ" to my LCD and pressed the enter key, with the serial window open and this came up
0 B B-...
1 K K-...
2 M M-...
3 D D-...
4 B B-...
5 Z Z-...

but have no bips to my speaker at all.

shouldn't that work just fine ?

does anyone have an idea why ?
29  Using Arduino / Programming Questions / Re: conbination of two codes ! (4x4 keypad to 16x2 lcd texter), morse EnDecoder ! on: February 15, 2014, 03:56:44 am
no bips at all.

serial print though is warking fine
0 A A.-1 M M.-2 J J.-3 T T.-4 W W.-5 P P.-6 G G.-

first it print the value of i
then the letter in sendMorse
and then the letterwith morse code right next.

so for loop working just fine,

the library recognise the char and decodes it to serial with the apropriate . and - !

BUT NO BIPS. smiley

ANY IDEA ON WHY ?

30  Using Arduino / Programming Questions / Re: conbination of two codes ! (4x4 keypad to 16x2 lcd texter), morse EnDecoder ! on: February 15, 2014, 03:52:14 am
First of all i would like to declare to the world that there is nothing like a good sleep to clear you head.

had my shower and a bucket of morning coffee smiley-grin and now i am ready to work.

thank you very much for your time man.

i saw that it needs some loops to do the ecncoding stuff. so i desided to creat a for loop like that inside my outputserial()

code is like that

Code:
void outputserial(){ //output message and display remaining characters to serial console
  for (int i=0; i<(positionintypedtext); i++){   // with this variant (positionintypedtext)it loops so many times, as many characters i have typed
  Serial.print(i);
 
  currentTime = (long)millis();
 
  // Needs to call these once per loop
  morseInput.decode();
  morseOutput.encode();

  // SEND MORSE (OUTPUT)
  // Encode and send text received from the serial port (serial monitor)
 
    // Get character from serial and send as Morse code
    char sendMorse = typedtext[i];
    morseOutput.write(sendMorse);
    Serial.print(' ');
    Serial.print(sendMorse);
    // Not strictly needed, but used to get morseSignalString before it is destroyed
    // (E.g. for morse training purposes)
    morseOutput.encode();

    // Also write sent character + Morse code to serial port/monitor
    Serial.write(' ');
    Serial.write(sendMorse);
    Serial.write(morseOutput.morseSignalString);
 


  // RECEIVE MORSE (INPUT)
  // If a character is decoded from the input, write it to serial port
  if (morseInput.available())
  {
    // Get decoded Morse code character and write it to serial port/monitor
    char receivedMorse = morseInput.read();
    Serial.print(receivedMorse);
   
    // A little error checking   
    if (receivedMorse == '#') Serial.println("< ERROR:too many morse signals! >");
  }


  // Local Morse code feedback from input if not sending Morse simultaneously
  if (morseOutput.available()) digitalWrite(morseOutPin, morseInput.morseSignalState);


  // Check if ongoing transmission (not yet transmission pause)
  if (!morseOutput.available() || morseInput.morseSignalState == true)
  {
    // reset last transmission timer and flag
    lastTransmissionTime = currentTime;
    transmissionEnded = false;
  }

  // Format output with carriage returns after a transmission pause
  if ((currentTime - lastTransmissionTime) > transmissionPaused)
  {
    if (transmissionEnded == false)
    {
      // Separate the transmissions somewhat in the serial monitor with CR's
      for (int cr=0; cr<2; cr++) Serial.println("");  // some carriage returns..
     
      // Finally set the flag to prevent continous carriage returns
      transmissionEnded = true;
    }
  }
}
  delay(preventholddelay); //delay a little to prevent continuous cycling
}

Pages: 1 [2] 3 4 ... 7