Show Posts
Pages: [1] 2 3 ... 7
1  Using Arduino / Programming Questions / Re: Help request interfacing a 4x4 keypad with Arduino on: Today at 10:07:35 am
well i was thinking in using photoresistors as inputs for my matrix keypad.

under a painted plexiglass surface living open spaces only for my 16 photoresistors.

so with every push of my finger over the photoresistor i would cover the light and get my push.

i am not really sure if those schematics are usable though. while it is not a button that allows current only when you press it.
photoresistors allow current all the time. how can i make a 4x4 matrix keypad with photoresistors ????????????

help !
2  Using Arduino / Programming Questions / Re: compilation problem with the switch on: February 24, 2014, 07:49:34 pm
I GIVE UP !

Code:
/*
microphone sketch
 
 SparkFun breakout board for Electret Microphone is connected to analog pin 0
 */
int i=0;
unsigned long currentTime  = 0; //this variable will be overwritten by millis() each iteration of loop
unsigned long pastTime     = 0; //no time has passed yet
unsigned long current  = 0; //this variable will be overwritten by millis() each iteration of loop
unsigned long past     = 0;
char* morseATable[] = {
  ".-00", "-...", "-.-.", "-..0", ".000", "..-.", "--.0",   // A-G
  "....", "..00", ".---", "_._0", ".-..", "--00", "-.00",    // H-N
  "---0", ".--.", "--.-", ".-.0", "...0", "-000", "..-0",    // O-U
  "...-", ".--0", "-..-", "-.--", "--.."               // V-Z
};
char* temp="0000";
byte c;
int flag2=0;
boolean first=true;
int           currentState = 0; //the default state
int           wait         = 100; //no need to wait, nothing has happened yet
int           flag         =0;
const int ledPin = 13;            //the code will flash the LED in pin 13
const int middleValue = 512;      //the middle of the range of analog values
const int numberOfSamples = 16;  //how many readings will be taken each time

int sample;                       //the value read from microphone each time
long signal;                      //the reading once you have removed DC offset
long averageReading;              //the average of that loop of readings

long runningAverage=0;          //the running average of calculated values
const int averagedOver= 4;     //how quickly new values affect running average
//bigger numbers mean slower

const int threshold=32000;        //at what level the light turns on

void setup() {
  pinMode(ledPin, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  long sumOfSquares = 0;
  for (int i=0; i<numberOfSamples; i++) { //take many readings and average them
    sample = analogRead(0);               //take a reading
    signal = (sample - middleValue);      //work out its offset from the center
    signal *= signal;                     //square it to make all values positive
    sumOfSquares += signal;               //add to the total
  }
  averageReading = sumOfSquares/numberOfSamples;     //calculate running average
  runningAverage=(((averagedOver-1)*runningAverage)+averageReading)/averagedOver;

  if (runningAverage>threshold){         //is average more than the threshold ?
    digitalWrite(ledPin, HIGH);    //if it is turn on the LED
    past = current; //currentTime at this point is the current time from the previous iteration, this should now be pastTime
    current = millis();
    unsigned long timePassed2 = current - past;
    if(timePassed2 > 200 && first==false){
      for (int b=0; b<26; b++){
        if (strcmp(temp, morseATable[b])==0){
          flag2=b;
          break;
        }
      }
      flag2=flag2+1;
      switch(flag2){
      case '1':
        c = "A";
        break;
      case '2':
        c = 'B';
        break;
      case '3':
        c = 'C';
        break;
      case '4':
        c = 'D';
        break;
      case '5':
        c = 'E';
        break;
      case '6':
        c = 'F';
        break;
      case '7':
        c = 'G';
        break;
      case '8':
        c = 'H';
        break;
      case '9':
        c = 'I';
        break;
      case '10':
        c = 'J';
        break;
      case '11':
        c ='K';
        break;
      case '12':
        c = 'L';
        break;
      case '13':
        c = 'M';
        break;
      case '14':
        c = 'N';
        break;
      case '15':
        c = 'O';
        break;
      case '16':
        c = 'P';
        break;
      case '17':
        c = 'Q';
        break;
      case '18':
        c = 'R';
        break;
      case '19':
        c = 'S';
        break;
      case '20':
        c = 'T';
        break;
      case '21':
        c = 'U';
        break;
      case '22':
        c = 'V';
        break;
      case '23':
        c = 'W';
        break;
      case '24':
        c = 'X';
        break;
      case '25':
        c = 'Y';
        break;
      case '26':
        c = 'Z';
        break;
      case ' ':
        c = ' ';
        break;
      }
      Serial.print("c :");
      Serial.println(c);
      Serial.print("flag2 :");
      Serial.println(flag2);
      Serial.print("temp :");
      Serial.println(temp);
      i=0;  
    }
    first=false;
  }
  else{
    digitalWrite(ledPin, LOW);           //if it isn't turn the LED off

    pastTime = currentTime; //currentTime at this point is the current time from the previous iteration, this should now be pastTime
    currentTime = millis();    //currentTime is now the current time (again).
    unsigned long timePassed = currentTime - pastTime; //this is roll-over proof, if currentTime is small, and pastTime large, the result rolls over to a small positive value, the time that has passed
    if(timePassed > 30 && timePassed <200) //part1 of the state engine
    {
      if(timePassed >= wait) //part1 of the state engine
      {
        Serial.print("timePassed :");
        Serial.println(timePassed);
        temp[i] = '-';
        i++;

      }
      else {
        Serial.print("timePassed :");
        Serial.println(timePassed);
        temp[i] = '.';
        i++;
      }
    }
    unsigned long timePassed2 = current - past;
    if (timePassed2 >200){
      first=false;
    }
  }
}

i tryed c as a char and a byte, and i tryed with ' and " in switch ( offcouse with " i get compilation errors ).
flag 2 is correct and points me, to the correct letter.

why i can not get the Serial.print(c); to print me the character of the switch ?
3  Using Arduino / Programming Questions / Re: compilation problem with the switch on: February 24, 2014, 06:10:29 pm
PAULS

i have responce from you even to my first post.

i would like to thank you man for the time you spend with noobs like me.

really i am lughing allone right here.

any way, your comments are sarcastic and unique ( in a way )  smiley-lol.

again thanks man.

i'll try to send the final code when i get the results i am hopping

4  Using Arduino / Programming Questions / Re: compilation problem with the switch on: February 24, 2014, 05:59:50 pm
ok i get the point.

so probably i need to  create a value like this
Code:
String morseATable[] = { ".-00", "-...", "-.-.", "-..0", ".000", "..-.", "--.0",   // A-G
                        "....", "..00", ".---", "_._0", ".-..", "--00", "-.00",    // H-N
                        "---0", ".--.", "--.-", ".-.0", "...0", "-000", "..-0",    // O-U
                        "...-", ".--0", "-..-", "-.--", "--.."               // V-Z
                      };

when my mic detectes a word space there is a value named temp (i should better make it a string), that hase the dots and dashes up so far detected. and if the dots and dashes are less than 3 in total it goes with a for loop and fills the rest of the value with zeros.

if i can not use a switch, what would be more eficient comparator according to your opinion ? compare the temp value with the morseATable using a for loop ( and if i do, how would i break out from a for loop ) ant use the i in a switch after that.

but i have to break out from the for loop other wise i have to pass the hole table ( even if the letter is A for example that it is the first),
and with an
Code:
if (temp = morseATable[i]){
flag=i
}

switch (flag):{
.................(then i can use '1') // they are integers right ????? :D
}


what do you thing about that ? do you thing that there is a more eficient way of doing it ?


 
5  Using Arduino / Programming Questions / compilation problem with the switch on: February 24, 2014, 04:49:51 pm
i have a problem with my case and i get compilation errors.

here is the code

Code:
/*
microphone sketch
 
 SparkFun breakout board for Electret Microphone is connected to analog pin 0
 */
 int i=0;
unsigned long currentTime  = 0; //this variable will be overwritten by millis() each iteration of loop
unsigned long pastTime     = 0; //no time has passed yet
unsigned long current  = 0; //this variable will be overwritten by millis() each iteration of loop
unsigned long past     = 0;
char letter[4];
char temp[4];
int           currentState = 0; //the default state
int           wait         = 100; //no need to wait, nothing has happened yet
int           flag         =0;
const int ledPin = 13;            //the code will flash the LED in pin 13
const int middleValue = 512;      //the middle of the range of analog values
const int numberOfSamples = 16;  //how many readings will be taken each time

int sample;                       //the value read from microphone each time
long signal;                      //the reading once you have removed DC offset
long averageReading;              //the average of that loop of readings

long runningAverage=0;          //the running average of calculated values
const int averagedOver= 4;     //how quickly new values affect running average
//bigger numbers mean slower

const int threshold=32000;        //at what level the light turns on

void setup() {
  pinMode(ledPin, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  long sumOfSquares = 0;
  for (int i=0; i<numberOfSamples; i++) { //take many readings and average them
    sample = analogRead(0);               //take a reading
    signal = (sample - middleValue);      //work out its offset from the center
    signal *= signal;                     //square it to make all values positive
    sumOfSquares += signal;               //add to the total
  }
  averageReading = sumOfSquares/numberOfSamples;     //calculate running average
  runningAverage=(((averagedOver-1)*runningAverage)+averageReading)/averagedOver;

  if (runningAverage>threshold){         //is average more than the threshold ?
    digitalWrite(ledPin, HIGH);    //if it is turn on the LED
    past = current; //currentTime at this point is the current time from the previous iteration, this should now be pastTime
    current = millis();
    unsigned long timePassed2 = current - past;
    if(timePassed2 > 200){
      switch(letter){
      case '.':
        temp = 'E';
        return;
      case '-':
        temp = 'T';
        return;
      case '.-':
        temp ='A';
        return;
      case '---':
        temp ='O';
        return;
      case '..':
        temp ='I';
        return;
      case '-.':
        temp='N';
        return;
      case '...':
        temp = 'S';
        return;
      case '....':
        temp = 'H'
          return;
      case '.-.':
        temp = 'R';
        return;
      case '-..':
        temp='D';
        return;
      case '.-..':
        temp='L';
        return;
      case '-.-.':
        temp ='C';
        return;
      case '..-':
        temp = 'U';
        return;
      case '--':
        temp = 'M';
        return;
      case '.--':
        temp = 'W';
        return;
      case '..-.':
        temp = 'F';
        return;
      case '--.':
        temp ='G';
        return;
      case '-.--':
        temp = 'Y';
        return;
      case '.--.':
        temp = 'P';
        return;
      case '-...':
        temp = 'B';
        return;
      case '...-':
        temp = 'V';
        return;
      case '-.-':
        temp = 'K';
        return;
      case '.---':
        temp = 'J';
        return;
      case '-..-':
        temp = 'X';
        return;
      case '--.-':
        temp = 'Q'
          return;
      case '--..':
        temp = 'Z';
        return;
      case ' ':
        delay(wgap);
        return;
      }
      Serial.print(temp);
      i=0;
    }
  }
  else{
    digitalWrite(ledPin, LOW);           //if it isn't turn the LED off

    pastTime = currentTime; //currentTime at this point is the current time from the previous iteration, this should now be pastTime
    currentTime = millis();    //currentTime is now the current time (again).
    unsigned long timePassed = currentTime - pastTime; //this is roll-over proof, if currentTime is small, and pastTime large, the result rolls over to a small positive value, the time that has passed
    if(timePassed > 30 && timePassed <200) //part1 of the state engine
    {
      if(timePassed >= wait) //part1 of the state engine
      {
        letter[i] = '-';
        i++;
      }
      else {
        letter[i] = '.';
        i++;
      }
    }
  }
}

it receives audio from analog0 and it counts the millis between the the values over the threshold to determin whether it is a dot or a dash.

it worked fine and i had to my serial seperated groups of - and . ! the next step is where the swich comes to check whether the value that i have is equal to on of this and print to my serial the apropriate letter.

case label does not reduse to an integer constant

this the compilation error that i get.

any ideas here ?
6  Using Arduino / Project Guidance / Re: Arduino 2 way comunication over fsk audio ? softmodem library ! can it be done ? on: February 24, 2014, 12:32:38 pm
Thank you BillHo for your reply.


so to understand here instead of ir led and photoresistor this were my audio IN/OUT is and a the reciever part i wont have analog inputs but digital. right ?
7  Using Arduino / Project Guidance / Re: Detecting Microphone Use on: February 24, 2014, 05:13:23 am
i had this code to an other projrct of mine,

adjust the thresshold value to your mic.

it will work for all analog ins in any arduino .


Code:
/*
microphone sketch
 
 SparkFun breakout board for Electret Microphone is connected to analog pin 0
 */

int           currentState = 0; //the default state
int           wait         = 100; //no need to wait, nothing has happened yet
int           flag         =0;
const int ledPin = 13;            //the code will flash the LED in pin 13
const int middleValue = 512;      //the middle of the range of analog values
const int numberOfSamples = 16;  //how many readings will be taken each time

int sample;                       //the value read from microphone each time
long signal;                      //the reading once you have removed DC offset
long averageReading;              //the average of that loop of readings

long runningAverage=0;          //the running average of calculated values
const int averagedOver= 4;     //how quickly new values affect running average
//bigger numbers mean slower

const int threshold=32000;        //at what level the light turns on

void setup() {
  pinMode(ledPin, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  long sumOfSquares = 0;
  for (int i=0; i<numberOfSamples; i++) { //take many readings and average them
    sample = analogRead(0);               //take a reading
    signal = (sample - middleValue);      //work out its offset from the center
    signal *= signal;                     //square it to make all values positive
    sumOfSquares += signal;               //add to the total
  }
  averageReading = sumOfSquares/numberOfSamples;     //calculate running average
  runningAverage=(((averagedOver-1)*runningAverage)+averageReading)/averagedOver;

  if (runningAverage>threshold){         //is average more than the threshold ?
    digitalWrite(ledPin, HIGH);    //if it is turn on the LED
  }
  else{
    digitalWrite(ledPin, LOW);           //if it isn't turn the LED off
  }
}
8  Using Arduino / Project Guidance / Re: Help Me ! Thanks First on: February 24, 2014, 05:05:43 am
in general you need to keep your track in to a basic idea.

what would be deferent from the time that someone come near or even touch the door

examples ( light, sound, temperature ect. )

after that you can creat in input point that continuisly check this value and at a change it trigers your output pin.

a door knob made from clear plexiglass dome with lightsensors in side would be my choise.

i am preaty sure that you can find everything easy.

for your first experiment at least while Paul is right, his idea is more apropriate.

smiley-grin

good luck with your project.
9  Using Arduino / Project Guidance / Re: Arduino 2 way comunication over fsk audio ? softmodem library ! can it be done ? on: February 24, 2014, 04:38:51 am
i now that it modulates to fsk. i don't know how to demodulate an fsk audio signal.

any help here ?
10  Using Arduino / Project Guidance / Arduino 2 way comunication over fsk audio ? softmodem library ! can it be done ? on: February 23, 2014, 04:57:48 pm
Hello community,

i am a member of a local volunteer search and rescue team, and i thought that this project would look handy


i've done it so far and it plays really ok. thanks to Clayton Ford.

no all i am thinking is to take it to an other level, and it did up so far.

here is my twist of the code until now.
http://pastebin.com/gqCbvbQe

it transmite everything to morse and it really works. all perfect until now.

i saw this library thow that can transmite in FSK
http://translate.google.com/translate?hl=en&prev=/search%3Fq%3Dhttp://www.switch-science.com/products/detail.php%253Fproduct_id%253D364%26hl%3Den%26client%3Dfirefox-a%26hs%3DL9M%26rlz%3D1R1GGLL_en___US367%26prmd%3Div&rurl=translate.google.com&sl=ja&twu=1&u=http://code.google.com/p/arms22/downloads/detail%3Fname%3DSoftModem-004.zip

i would like to enclose it and have on the enclosure 2 x 3.5 mm female audio http://media.digikey.com/photos/CUI%20Photos/SJ-3523-SMT.jpg

one for line in
one for line out

now my problem is can i use this library to conect my 2 arduino uno so i can send a text message of 64 characters ?

and i go for audio while the place that i leave is volcanic and sismic active, there is a high chance in a case of an hard earthquake or volcanic eruption to stay with out gsm, 3g, 4g, wifi or even power smiley-grin.

as i said i am a member of a volunteer search and rescue tem and i would like to creat a rawbust - versatile text messager that can be versatile.
arduino to audio -----> walkie talkie / radio, phone line, uhf, vhf ------> audio to arduino

so does anyone thing that this libraby can do the job ?
11  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
12  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);
}
13  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 ?
14  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?
15  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 ?


Pages: [1] 2 3 ... 7