Show Posts
Pages: 1 [2] 3 4 ... 6
16  Using Arduino / Sensors / Re: MQ-2 Gas sensor , how to get sensor value on: December 07, 2012, 07:48:08 pm
I used 20kΩ resistor... im woried about connecting it correct... which way is the correct ?

this http://arduinotronics.blogspot.gr/2012/03/gas-sensor-tutorial.html is a littel confusing...
17  Using Arduino / Sensors / Re: MQ-2 Gas sensor , how to get sensor value on: December 07, 2012, 07:19:58 pm
Tutorial http://arduinotronics.blogspot.gr/2012/03/gas-sensor-tutorial.html
Datasheet http://www.pololu.com/file/0J309/MQ2.pdf
Tutorial http://www.geeetech.com/wiki/index.php/Gas_Sensor_-_MQ-2
18  Using Arduino / Sensors / MQ-2 Gas sensor , how to get sensor value on: December 07, 2012, 07:03:22 pm
Code:

void setup() {
  Serial.begin(9600);
}

void loop() {

 sensorValue = analogRead(A0);  //tried 14 with same results...         
 Serial.print("sensor = " );                       
 Serial.println(sensorValue);     
  delay(10);                     
}


At my serial box i get only 1023.... this is it... If i messure the voltage with voltmeter , it works , it increases volts when it detects gas... from 5.10V it goes to 5.16V

How can i make it work ? thanks !
19  Using Arduino / Programming Questions / Re: How to simplify this easy function on: December 07, 2012, 11:35:29 am
Code:
//do not touch
#define numOfRegisterPins number_of_74hc595s * 8
You really should touch it :
Code:
//do not touch
#define numOfRegisterPins (number_of_74hc595s * 8)
   smiley-cool

I didn't use it smiley i work with 1 chip smiley so its 8 from the start for me. thanks anyway !
20  Using Arduino / Programming Questions / Re: How to simplify this easy function on: December 07, 2012, 11:01:36 am
Did it compile OK?

No... smiley-wink its define instead of Define !

Just curious, don't you need to turn off whatever LED was on before you turn on something else?

Good comment ! Yes i turn off all leds and then i light which i want... I took this example http://bildr.org/2011/02/74hc595/ and tried to work with the code

Code:
int SER_Pin = 8;   //pin 14 on the 75HC595
int RCLK_Pin = 9;  //pin 12 on the 75HC595
int SRCLK_Pin = 10; //pin 11 on the 75HC595

//How many of the shift registers - change this
#define number_of_74hc595s 1

//do not touch
#define numOfRegisterPins number_of_74hc595s * 8

boolean registers[numOfRegisterPins];

void setup(){
  pinMode(SER_Pin, OUTPUT);
  pinMode(RCLK_Pin, OUTPUT);
  pinMode(SRCLK_Pin, OUTPUT);

  //reset all register pins
  clearRegisters();
  writeRegisters();
}               

//set all register pins to LOW
void clearRegisters(){
  for(int i = numOfRegisterPins - 1; i >=  0; i--){
     registers[i] = LOW;
  }
}

//Set and display registers
//Only call AFTER all values are set how you would like (slow otherwise)
void writeRegisters(){

  digitalWrite(RCLK_Pin, LOW);

  for(int i = numOfRegisterPins - 1; i >=  0; i--){
    digitalWrite(SRCLK_Pin, LOW);

    int val = registers[i];

    digitalWrite(SER_Pin, val);
    digitalWrite(SRCLK_Pin, HIGH);

  }
  digitalWrite(RCLK_Pin, HIGH);

}

//set an individual pin HIGH or LOW
void setRegisterPin(int index, int value){
  registers[index] = value;
}

void loop(){

  setRegisterPin(2, HIGH);
  setRegisterPin(3, HIGH);
  setRegisterPin(4, LOW);
  setRegisterPin(5, HIGH);
  setRegisterPin(7, HIGH);

  writeRegisters();  //MUST BE CALLED TO DISPLAY CHANGES
  //Only call once after the values are set how you need.
}

so my code is....

Code:
void leds_off(int led_row){
   
for(int i = 0; i <  8; i++){
if (led_row == LEDS_L) { leds_left[i] = LOW; }
else if (led_row == LEDS_R) { leds_right[i] = LOW; }
}
toggle_leds(led_row);
 
 
}

void toggle_leds(int led_row){

  led_row = pin_of[led_row];
 
  digitalWrite(led_row+1, LOW);

  for(int i = 0; i <  8; i++){
digitalWrite(led_row+2, LOW);

int val = leds_left[i]; //here i have to put an if staement... I know how to fix it

digitalWrite(led_row, val);
digitalWrite(led_row+2, HIGH);

  }
  digitalWrite(led_row+1, HIGH);
}

void setRegisterPin(int index, int value, int led_row){

  if (led_row == LEDS_L) { leds_left[index] = value; }
  else if (led_row == LEDS_R) { leds_right[index] = value; }
 
  toggle_leds(led_row);
}

void loop(){

leds_off(LEDS_L);
leds_off(LEDS_R);

setRegisterPin(led_row, HIGH , LEDS_L);
setRegisterPin(led_row, HIGH , LEDS_R);
}
21  Using Arduino / Programming Questions / Re: How to simplify this easy function on: December 07, 2012, 01:31:28 am
I replaced strings and now i use an array

Code:
void leds_off(int led_row){
   
for(int i = 0; i <  8; i++){
if (led_row == LEDS_L) { leds_left[i] = LOW; }
else if (led_row == LEDS_R) { leds_right[i] = LOW; }
else if (led_row == LEDS_C) { leds_center[i] = LOW; }
}
toggle_leds(led_row);
 
 
}

void toggle_leds(int led_row){

  led_row = pin_of[led_row];
 
  digitalWrite(led_row+1, LOW);

  for(int i = 0; i <  e; i++){
digitalWrite(led_row+2, LOW);

int val = leds_left[i];

digitalWrite(led_row, val);
digitalWrite(led_row+2, HIGH);

  }
  digitalWrite(led_row+1, HIGH);
}


also used...
#Define LEDS_L 4
#Define LEDS_R 5
#Define LEDS_C 6

and pin_of is an array...

EDIT: aaaah just found out that int val = leds_left; has to be replaced with an if statement , to know "which" of left right or center leds should it use...
22  Using Arduino / Programming Questions / Re: How to simplify this easy function on: December 06, 2012, 06:17:53 pm
Thank you all it was very helpfull!!! i wil go with MarkT example
23  Using Arduino / Programming Questions / How to simplify this easy function on: December 05, 2012, 07:37:33 pm
Hello , can someone help me with my thought ? I have this function which i want to simplify...

Code:
void leds_off(String row){

  if (row == "left") {
 
  digitalWrite(left_Pin, LOW);

  }
  else if (row == "right") {
 
  digitalWrite(right_Pin, LOW);
  }
  else if (row == "center") {
 
  digitalWrite(center_Pin, LOW);
  }
}

I thought it would be great to get rid of the "if" statement and change the name o left_Pin,right_Pin,center_Pin dynamically somehow...

Code:
I know its wrong but i want to give you an idea of what i want to do !

void leds_off(String row){
   
  digitalWrite(row + _Pin, LOW);
}

Thanks !
24  Using Arduino / General Electronics / Short circuit or something else ?? on: December 01, 2012, 07:09:44 pm
Hello i have a problem with my wiring... probably....

Im using 3 of these , i have common GND for all 24 leds and chips , and when i feed the chips with 5V without arduino connection , 3 "command" (purple,blue,orange) wires are to "air" , the leds from the 2 chips are off,  the other one is on , when i start touching the 3 cables of each chip,  the leds of the chip are flickering...
25  Using Arduino / Networking, Protocols, and Devices / Re: Cellular Shield with SM5100B , worked for a while , but not any more.... on: November 28, 2012, 03:56:46 pm
Did you remember to connect GND between the GSM shield and the Arduino as well?

no i didn't is that necessary ?
26  Using Arduino / Networking, Protocols, and Devices / Cellular Shield with SM5100B , worked for a while , but not any more.... on: November 28, 2012, 01:29:16 pm
Hello , im trying to connect https://www.sparkfun.com/products/9607 to my arduino UNO. As mentioned here http://tronixstuff.wordpress.com/2011/01/19/tutorial-arduino-and-gsm-cellular-part-one/ it needs 5V@2A , from 5V pin in order to power up. This is because arduino UNO has a regulator capable of 800mA and the shield needs 2A and it cant power the shield  up from DC. Ok i understand this , but i dont need it !

I want to connect the shield with my arduino but not to put it on the top of it with stackable headers, so i added an external power supply 5V@>2A to Vin GND of the shield and connected pins 2,3 from shield with pins 2,3 of arduino. Using the very first sketch (found at sparkfun site too) it seemed to work properly... and i was getting SIND: 4.

After some tries , now it doesnt work anymore , i dont get any SIND status from the shield , BUT if i use a terminal program https://sites.google.com/site/terminalbpp/ in order to "talk" to the shield , it answers as expected... for example AT+SBAND? will answer that im using 4 SBAND.

Any idea ? thanks !
27  Using Arduino / Networking, Protocols, and Devices / Re: Is there any difference between antennas ? on: November 18, 2012, 06:32:02 pm
thanks !
28  Using Arduino / Networking, Protocols, and Devices / Is there any difference between antennas ? on: November 18, 2012, 05:14:30 pm
Hello is there any difference between this https://www.sparkfun.com/products/675 and a standard wifi router antenna ? I want to connect my antenna to https://www.sparkfun.com/products/9533 and want to know if its compartible or i will need to buy a new one...

The female to male connector is not what considers me...
29  Using Arduino / Networking, Protocols, and Devices / Re: How to wire arduino UNO with Cellular Shield on: November 18, 2012, 03:53:50 pm
Thanks ! i cant imagine how GND pin is working but you are right , schematics are schematics... I dont really understood the hardware and software serial , but i will use 2,3 because i think my code is for software serial use...

Thanks !
30  Using Arduino / Networking, Protocols, and Devices / How to wire arduino UNO with Cellular Shield on: November 18, 2012, 12:50:29 am
Hello forum , i have arduino UNO R3 and https://www.sparkfun.com/products/9607 this shield.

I dont have stackable headers in order to make my life easier but i have these https://www.sparkfun.com/products/116 .

So what im asking... Which taps of the shield have to be wired ? I want to have the shield next to arduino and not in top of.....

So what im thinking as i examine the shield , i cant see any engraved lines at analog In 0-5 so i think they are optional taps.
8-AREF , i think these taps are optional too , there are no engraved lines there....
7-4 there are no lines so its optional.

tap 3 has a line at the back side. I think i will need it as i will need tap 2 , RX and TX.
Finally i can see lines at Vin and RST

So , it needs RX,TX,2,3,Vin,RST ? is this correct? I think it has to be a GND somewhere.....

Thanks !
Pages: 1 [2] 3 4 ... 6