Pages: [1]   Go Down
Author Topic: Arduino cant give power to an LED  (Read 667 times)
0 Members and 1 Guest are viewing this topic.
India
Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I was doing a project with TSOP, a 12v fan, LED, and a buzzer all taking power from ardunio. Yes, i agree it drew way too much current than arduino could provide. The project was to activate the fan, led or buzzer by pressing the remote control of my tv. Since only one of them was activated at once, i was not worried. The fan was spinning but only at a low speed. LED was lighting up well as well coz when i turn on LED, the fan stops. All according to the plan. I am using IRremote library. After some time, only one of the components were working properly. If the first component is fan, then it will spin as usual, but the second component, LED will only light up a little. I found out that current to LED is very low. I think my arduino is destroyed. Help please. Here is my code too, see if anythings wrong

Code:
/*
 * IRremote: IRrecvDemo - demonstrates receiving IR codes with IRrecv
 * An IR detector/demodulator must be connected to the input RECV_PIN.
 * Version 0.1 July, 2009
 * Copyright 2009 Ken Shirriff
 * http://arcfn.com
 */

#include <IRremote.h>

int RECV_PIN = 11;
int ledPin = 5;
int fan=8;
IRrecv irrecv(RECV_PIN);

decode_results results;

void setup()
{pinMode(ledPin,OUTPUT);
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
}

void loop() {
  digitalWrite(ledPin,LOW);
  if (irrecv.decode(&results)) {
    Serial.println(results.value, HEX);
    irrecv.resume(); // Receive the next value
  }
  if(results.value ==2)
    digitalWrite(ledPin,HIGH);
    else
    digitalWrite(ledPin,LOW);

  if(results.value ==1){
    digitalWrite(fan,HIGH);
    delay(500);
    digitalWrite(fan,LOW);
 
  }
  }
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 533
Posts: 26943
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Please post your schematic/wiring as well.

You're missing this statement for the fan pin:
Code:
pinMode(ledPin,OUTPUT);
Am surprised it ever turned on; writing the pin hi/lo here
Code:
    digitalWrite(fan,HIGH);
    delay(500);
    digitalWrite(fan,LOW);
only enables/disables the internal pullup resistor.

I don't see anything that talks about a  buzzer.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

India
Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

THanks, corrected the errors abt the code, some more problems remaining
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17292
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Please post your schematic/wiring as well.

You're missing this statement for the fan pin:
Code:
pinMode(ledPin,OUTPUT);
Am surprised it ever turned on; writing the pin hi/lo here
Code:
    digitalWrite(fan,HIGH);
    delay(500);
    digitalWrite(fan,LOW);
only enables/disables the internal pullup resistor.

I don't see anything that talks about a  buzzer.

With today's more efficient LEDs even the small amount of current that the input pin internal pull-up resistor can provide will be seen in most leds as he enables and disables the pull-up in the sketch. Try it sometime.
Logged

India
Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey, that was an error :p Can any one help me why the serial number thats received from my remote shows "1", "801" "FFFFFFF" for the same button i press?
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 533
Posts: 26943
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I would try clearing results.value after you use them, so they are not holding the same value during the next pass thru loop. And add some { }s

Code:
  if(results.value ==2){
    digitalWrite(ledPin,HIGH);
results.value = 0;
}
    else{
    digitalWrite(ledPin,LOW);
}

  if(results.value ==1){
    digitalWrite(fan,HIGH);
    delay(500);
    digitalWrite(fan,LOW);
results.value = 0;
  }
results.value = 0; // bad result received
} // end loop
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Offline Offline
Newbie
*
Karma: 0
Posts: 49
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey, that was an error :p Can any one help me why the serial number thats received from my remote shows "1", "801" "FFFFFFF" for the same button i press?

FFFFFFFF is the repeat code for a lot of remotes. If you press the same button twice within a short amount of time, or hold it down, the first code it sends is the actual key code, followed by one or more FFFFFFFF codes.

The fact the first code can differ could be down to improper reception or interference.
Logged

Germany
Offline Offline
Faraday Member
**
Karma: 56
Posts: 3001
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Alternating 0x0001 and 0x0801 is normal for lots of Remotes (of mine, at least), to distinguish two presses of the the same button from a longer press of the same button.
Logged

Pages: [1]   Go Up
Jump to: