Show Posts
Pages: [1] 2 3 ... 6
1  International / India / Re: controlling 220V relay with arduino on: March 19, 2014, 03:22:03 am
You need to use 5V or 12 V relay for isolation.  See the the link http://playground.arduino.cc/uploads/Main/relays.pdf for reference. You need to choose the rating of the relay in terms of AMPs that can handle the load of your immersion rod.
2  Using Arduino / Sensors / Re: PIR issue to run sketch on: March 13, 2014, 01:20:43 am
You are missing braces and also need to remove the semicolon at the end of if statement. I have modified your code
Code:
// Simulation of a dragstrip light tree.
  int stage1a = 2;
  int stage2a = 7;
  int stage1b = 3;
  int stage2b = 5;
  int tree1 =   4;
  int tree2 =   6;
  int tree3 =   8;
  int greengo = 10;
  int pirpin = 12;
  int led = 13;

// setup
void setup() {           
  pinMode(stage1a, OUTPUT);     
  pinMode(stage2a, OUTPUT);     
  pinMode(stage1b, OUTPUT);     
  pinMode(stage2b, OUTPUT);   
  pinMode(tree1, OUTPUT);     
  pinMode(tree2, OUTPUT);     
  pinMode(tree3, OUTPUT);     
  pinMode(greengo, OUTPUT);
  pinMode(led, OUTPUT); 
  randomSeed(analogRead(0));
  pinMode(pirpin, INPUT);
  delay(2000);
}

void loop() {
  if (digitalRead(pirpin) == HIGH)
  {
  digitalWrite(stage1a, HIGH);
  delay(random(300,2000));    // throw in a random delay for the next staging
  digitalWrite(stage2a, HIGH);
  delay(random(1500,3000));    // throw in a random delay for the next staging
  digitalWrite(stage1b, HIGH);
  delay(random(300,1500));    // throw in a random delay for the next staging
  digitalWrite(stage2b, HIGH);
  delay(500);
  digitalWrite(tree1, HIGH);
  delay(500);
  digitalWrite(tree1, LOW);
  digitalWrite(tree2, HIGH);
  delay(500);
  digitalWrite(tree2, LOW);
  digitalWrite(tree3, HIGH);
  delay(500);
  digitalWrite(tree3, LOW);
  digitalWrite(greengo, HIGH);
  digitalWrite(stage1a, LOW);
  delay(35);
  digitalWrite(stage1b, LOW);
  delay(71);
  digitalWrite(stage2b, LOW);
  digitalWrite(stage2a, LOW);
  delay(5000);
  digitalWrite(pirpin, LOW);
  digitalWrite(greengo, LOW);
  digitalWrite(led,1);
  delay(100);
  digitalWrite(led,0);
}

else

{
  delay(50000);
}

}
3  Using Arduino / Sensors / Re: PIR issue to run sketch on: March 12, 2014, 01:59:16 am
If I understand correctly, you need to attach a PIR sensor module and have the code run when there is a motion detected?  If yes, define one of the digital pin as input pin and connect the output of the PIR sensor to that digital pin.  when there is a moment, the  output of the PIR sensor goes high.  Use if statement like this
Code:
if (digitalread(sensorPin) == HIGH)
{
//put your code here
}

else

{
//do nothing or anything that you want to execute
}

hope it helps!
4  International / India / Re: Regarding purchase of Instrumentation amplifiers on: March 11, 2014, 10:24:28 am
Its available Vishal electronics, Bangalore.
5  Using Arduino / Programming Questions / Re: Replacing delay with millis on: March 05, 2014, 01:34:49 am
Thank you Mike!... I appreciate your guidance
6  Using Arduino / Programming Questions / Re: Replacing delay with millis on: March 04, 2014, 10:47:57 am
I appreciate that you are trying to help me, but I believe you did not look at the code I posted.  I am already using millis in my code its working fine.  But I am not able to use it repeatedly.  In this example, I need to call delay of 2000 ms in for loop and again 300 ms while loop.  I have successfully replaced the delay with millis in while loop, what I am looking is some guidance on how to deal the same in the forloop to replace the delay of 2000 ms with millis.
7  Using Arduino / Programming Questions / Replacing delay with millis on: March 03, 2014, 01:29:31 pm
Hello Friends!

I am using below sketch to scroll the test on LCD.  It works fine with delay function, but I want to replace delay with millis.  I could do that in the while loop successfully, but I need help in replacing the delay(2000) in for loop, any help is appreciated.

Thanks in advance.

Code:
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
const int numRows = 2;
const int numCols = 16;
void setup()
{
// set up the LCD's number of columns and rows:
lcd.begin(numCols, numRows);
}
void loop()
{
scroll("A message too long to fit !");
delay(1000);
lcd.clear();
}


void scroll( char *text)
{
long interval = 500;
long previousMillis = 0;
long previousMillis1 = 0;
int length = strlen(text); // the number of characters in the text
if(length < numCols)
lcd.print(text);
else
{
int pos;
for( pos = 0; pos < numCols; pos++)
lcd.print(text[pos]);
delay(2000); // allow time to read the first line before scrolling
 pos=1;
/*unsigned long currentMillis1 = millis();   // need help here, its not working.
if (currentMillis1 - previousMillis1 >4*interval)
  {
     previousMillis1 = currentMillis1;
      pos=1; 
 }
*/

while(pos <= length - numCols)
{
lcd.setCursor(0,0);
for( int i=0; i < numCols; i++)
lcd.print(text[pos+i]);
//delay(300);
//pos = pos + 1;
unsigned currentMillis = millis();
if (currentMillis - previousMillis > interval)
  {
   pos = pos + 1;
   previousMillis = currentMillis;
   }
}
}
}
8  Using Arduino / General Electronics / Re: 7 segment resistor on: March 03, 2014, 08:00:27 am
You can calculate the resister value with below link, but you need know voltage drop and led current.

http://www.hobby-hour.com/electronics/ledcalc.php
9  Using Arduino / Sensors / Re: MPX4250AP Sensor on: March 02, 2014, 11:34:22 am
There will be some fluctuation on the analogRead.  Have you tried smoothing example?  http://arduino.cc/en/Tutorial/Smoothing#.UxNeZfmSyIg
10  Using Arduino / Sensors / Re: MPX4250AP Sensor on: February 28, 2014, 10:16:06 am
You mean analog read is fluctuating?

11  Using Arduino / Sensors / Re: Concatenate two char arrays (for udp client) on: February 28, 2014, 09:46:48 am
Thanks for your direction.  Got the answer from the printf statement guide.  Below one does the trick.

Code:
sprintf(myConcatenation,"%s = %i%%",myCharArray,myInt)
12  Using Arduino / Sensors / Re: Concatenate two char arrays (for udp client) on: February 27, 2014, 11:06:43 am
Ok.  Figured it out myself with below code.  Is there any other better way to achieve it?

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

void loop() {

    char myConcatenation[80];
    char myCharArray[]="A variable name";
    int myInt=5;
    char myStr[] = "%";
    sprintf(myConcatenation,"%s = %i %s",myCharArray,myInt,myStr);
    Serial.println(myConcatenation);
    delay(100);
}
13  Using Arduino / Sensors / Re: Concatenate two char arrays (for udp client) on: February 27, 2014, 09:38:20 am
Hello Friends,  I am exploring the below sketch to concatenate  arrays..  If I want to add "%" symbol to the end of the integer value to myConcatenation[80] array, how do I do it?  basically, when I print myConcatenation, I would like to see the output as "A variable name = 5 %.

Any guidance is appreciated.

Code:
void setup() {
  Serial.begin(115200);
}

void loop() {

    char myConcatenation[80];
    char myCharArray[16]="A variable name";
    int myInt=5;
    sprintf(myConcatenation,"%s = %i",myCharArray,myInt);
    Serial.println(myConcatenation);
    delay(100);
}
14  Using Arduino / General Electronics / Re: Antenna for 315MHz RF on: February 17, 2014, 02:55:34 am
I have faced the similar situation.  In my case my TX module data sheet says, operating voltage range is 3 to 12 V.  When I powered the TX module with 5V source, range was much less compared to attached to a 12 V source.  Not sure its the same case with you?
15  Using Arduino / Programming Questions / Re: Question on Switch case statement on: February 17, 2014, 02:32:29 am
Thank you all for your responses!
Pages: [1] 2 3 ... 6