simple LED circuit not working with PWM/digital pins.

i have an Arduino MEGA.
**
this is what im trying to do:

go to: 3:38
**

  • i am trying to use pin 12 to power a 12V halogen light. i do not currently have a breadboard so i am just connecting by simple wire. it works when i connect to the 5V or 3.3V socket, but not pin 12 (PWM).
    it was configured correctly i believe, so i checked with a multimeter, the result is between ground and pin 12 i get 5V.
  • i am very new to electronics, so i do not not how it is possible to have a voltage but no current/power. my guess is that there is some resistance in the arduino, therefore it could be a configuration issue.
  • when i measured the voltage (with a multimeter) while connecting the halogen light simultaniously (quite hard to perform with 2 hands) i get only 0.3V.
  • have also tried using other pins including digital and analog, with no success.

here is the code:

void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);
pinMode(12, OUTPUT);
pinMode(A0, OUTPUT);
pinMode(32, OUTPUT);

}

void loop() {

digitalWrite(12, HIGH);
digitalWrite(32, HIGH);
analogWrite(A0, HIGH);
}

Upload a sketch of your schematic (on paper and a mobile phone photo loaded on imgur is fine!).

Not quite understanding what you are trying to do here...

You're trying to power a light bulb directly from a digital output pin?!

analogWrite(A0, HIGH);

Read this:
https://www.arduino.cc/en/Reference/AnalogWrite

Is A0 in the list for MEGA analogWrite(pin, value)?

Johnny010:
Upload a sketch of your schematic (on paper and a mobile phone photo loaded on imgur is fine!).

Not quite understanding what you are trying to do here…

this is what im trying to do: Imgur: The magic of the Internet

MK1888:
You’re trying to power a light bulb directly from a digital output pin?!

yes i am, im trying to imitate this link: Arduino Tutorial #1 - Digital Inputs and Outputs - Button & LED - YouTube

OP's pic:

i have an Arduino MEGA.

But your "circuit diagram" shows a Uno

 analogWrite(A0, HIGH);

Is the equivalent of

 analogWrite(A0, 1);

Even if the Arduino could supply enough current to light the bulb how bright would you expect it to be ?

i am, im trying to imitate this link: Arduino Tutorial #1 - Digital Inputs and Outputs - Button & LED - YouTube

The video shows an LED but you say

i am trying to use pin 12 to power a 12V halogen light

Do you appreciate the difference between an LED and your halogen light ?

UKHeliBob:
But your "circuit diagram" shows a Uno

 analogWrite(A0, HIGH);

Is the equivalent of

 analogWrite(A0, 1);

Even if the Arduino could supply enough current to light the bulb how bright would you expect it to be ?
The video shows an LED but you sayDo you appreciate the difference between an LED and your halogen light ?

thank you for your help (and all of the others).

  1. i have noticed this (the Uno/Mega issue), but i have measured the difference between high and low and it 5V of difference. i have also tried putting in '1' now that you suggested this and it works like 'HIGH'.
  2. currently it is a holiday so i am stuck with the halogen (pun unintended). but it works even with the 3.3 pin in the arduino.

ok finally i got another LED and it worked.