Show Posts
Pages: [1] 2 3 ... 7
1  Using Arduino / Programming Questions / Re: first attiny84 project on: May 23, 2014, 02:43:18 pm
ok ! witch pin should i use for output 10, 9 or 8 ?

and ofcourse how should i start the hole programming ?

do i just start to declare the pins ( input output ) ?

void setup {

}


void loop {

}

like i would in normal arduino ?

is there something else that i should do as well ?
2  Using Arduino / Programming Questions / Re: first attiny84 project on: May 23, 2014, 02:18:50 pm
http://highlowtech.org/wp-content/uploads/2011/10/ATtiny44-84.png

analog pin 0 ..... analog pin 7 !

do i miss something here ?
3  Using Arduino / Programming Questions / first attiny84 project on: May 23, 2014, 01:05:53 pm
hello world.

i have 8 photoresistors and i would like to connect them to an attiny84 so when ever one of them is out of light, i would like it to send to my arduino uno a message that "photoresistor 1" .... "photoresistor 8" is out of light, so i can send it to my serial screen.

the thing is i'v never worked with attiny at all and i don't know even where to begin with.

any one has any idea?

help

thank you very much for your time
4  Using Arduino / General Electronics / Re: photoresistors as input in 4x4 matrix keypad ! is it posible ????????? on: April 26, 2014, 04:56:35 am
pelle thank you very much for your reply.

i'll give it a try this weekend !
5  Using Arduino / General Electronics / photoresistors as input in 4x4 matrix keypad ! is it posible ????????? on: April 26, 2014, 04:24:21 am
Hello to everyone !

was thinking of putting 16 photoresistors in 4x4 matrix and take their data when i put my finger over them so i completely cover the light as a press of a button.

my question is " IS IT POSSIBLE " ????????????????????

if i am correct to a normal 16 btn 4x4 matrix keypad everything is connected to the digital connections, so the microcontroler knows every time on witch input what output is presenting.

photoresistors are analog, the close the circuit all the time ( for a digital input pin ) and an analog input ( witch is the most appropriate input for this project ) can not read digital outputs.

is my thinking correct ?
am i missing something here ?

is there a way to do something like that ?

i was thinking of some analog to digital converters, but everything is a little bit messy in my head at the moment.
can you help me ?
6  Using Arduino / Programming Questions / Re: Help request interfacing a 4x4 keypad with Arduino on: April 18, 2014, 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 !
7  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 ?
8  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

9  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 ?


 
10  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 ?
11  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 ?
12  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
  }
}
13  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.
14  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 ?
15  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 ?
Pages: [1] 2 3 ... 7