Show Posts
Pages: 1 ... 6 7 [8] 9 10 ... 23
106  Using Arduino / Programming Questions / Re: Ultrasonic Sensor on: July 06, 2013, 11:26:51 am
How did I convert it ? I just get myself too confused with that smiley-sad
107  Using Arduino / Programming Questions / Re: Ultrasonic Sensor on: July 06, 2013, 11:14:56 am
Okay, now I am suck in the unit conversion. Get confused although I know the facts LOL.

Anyone ?
108  Using Arduino / Programming Questions / Ultrasonic Sensor on: July 06, 2013, 10:53:32 am
Code:
#define trigPin 9
#define echoPin 8


void setup() {
  Serial.begin (9600);
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);

}

void loop() {
  long duration, distance;
  digitalWrite(trigPin, LOW);  // Added this line
  delayMicroseconds(2); // Added this line
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10); // Added this line
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH);
  distance = duration*340 / 20000;
 
 
    Serial.print(distance);
    Serial.println(" cm");
    delay(500);
  }
 

Hey guys, this is the code that I get somewhere else online.

Can anyone try to explain to me why is the calculation for distance is such ? I understand that thius is the formula for distance  = time* velocity. How does that 20000 comes from ? I know that the distance that we interest in have to be divided by 2. So I guesse there is where the 2 comes from but why multiple 10 power of 4 ?

Thanks !
109  Using Arduino / Project Guidance / Creating my own TV remote control on: June 30, 2013, 01:20:11 pm
Hey guys, recently I am playing around with the IR sensor used in television. So, I deal with the TV remote control. I would like to ask that how am I able to make my custom remote control ? I need encoder IC ? Or how can I do it instead of using those ready-made remote control ?

Thanks for help ! smiley
110  Using Arduino / Programming Questions / Re: DS1307 RTClib on: June 30, 2013, 04:08:21 am
Hey guys, wanna ask something regarding to DS1307 IC. I am using the RTClib. Okay, when I upload the sample coding to my arduino, the time will be set at the time the code being compile right ? So, if once done uploaded, then I re-compile again after like 5 minutes then upload, will the time been overwrite ? It seems to me not to be overwrite if I upload the same code with 'RTC.adjust(DateTime(__DATE__, __TIME__));' uncomment. If first time I uncomment that line and uploade to my arduino, then later on I upload again by commenting that line, then at maybe like after 10 minutes, I upload again the initialy code with 'RTC.adjust(DateTime(__DATE__, __TIME__));' uncomment, the time will change to the latest time I compile and upload the code. Can someone verify this to me ?

Thanks !
111  Using Arduino / Programming Questions / Re: DS1307 RTClib on: June 25, 2013, 03:13:17 am
Above mention library refer to Time.alarm ?
112  Using Arduino / Programming Questions / Re: DS1307 RTClib on: June 25, 2013, 02:50:53 am
How if I want to do something with delay when the alarm is ON ?

Thnaks
113  Using Arduino / Programming Questions / Re: DS1307 RTClib on: June 25, 2013, 02:28:58 am
So you mean I does not put any delay in the alarm function then ?

Thanks
114  Using Arduino / Programming Questions / Re: DS1307 RTClib on: June 25, 2013, 02:02:14 am
You mean while the alarm is on, I am not displaying the current time now ?

Thanks
115  Using Arduino / Programming Questions / Re: DS1307 RTClib on: June 25, 2013, 01:14:06 am
I am now trying to make alarm based on this rtclib. Any ideas ? Am still trying smiley

I just use an if

  if (hour == 0 && minute == 0 && second <2)
  {
  tralala;
           }

but I am only interested in changing the filename at midnight. If you want to do more sophisticated things there is an excellent pair of libraries, Time.h and TimeAlarms.h which seem to cover pretty well anything you can think of.

This can't work. If I were to add a delay(1000) in the alarm function, then initially, my seconds will be like this - 1,2,3,4,5......
If the alarm rang, means it is running the alarm functions and add on the delay(1000) too, so the seconds sequence would be 1,3,5,7,9

How to solve this ?

Thanks !

116  Using Arduino / Programming Questions / Re: DS1307 RTClib on: June 25, 2013, 12:40:50 am
How do I program it ? I am unsure about the function available in rtclib. Please guide smiley-sad
117  Using Arduino / Programming Questions / Re: DS1307 RTClib on: June 25, 2013, 12:35:15 am
Can I do like this ?
Code:
if((now.minute(),DEC) >30)
  {
    digitalWrite(8,HIGH);
    delay(1000);
    digitalWrite(8,LOW);
    delay(500);
  }
Pin 8 is connected to a buzzer.I want the alarm to sounds when the minutes is more than 30

Thanks
118  Using Arduino / Programming Questions / Re: DS1307 RTClib on: June 25, 2013, 12:09:26 am
That's alright. Using array can reduce your code maybe by 90% from using switch cases. Unless you will be doing some very different things for each case, you can use array's index in place of switch cases. On the other hand, if you later decide that every Monday is "holy" and needs to be called holyday and hail "lord ardin" then you have to give up the array method and get back to your switch cases. It all depends on situation.
Yup! Get it !

Anyway, I am now trying to make alarm based on this rtclib. Any ideas ? Am still trying smiley
119  Using Arduino / Programming Questions / Re: DS1307 RTClib on: June 24, 2013, 11:45:41 pm
Thanks !

It is just because my array basic is not strong. So I misunderstand about that.

Appreciate your help ! smiley
120  Using Arduino / Programming Questions / Re: DS1307 RTClib on: June 24, 2013, 11:19:02 pm
So if DOW[1][4], it will display MON ?
Pages: 1 ... 6 7 [8] 9 10 ... 23