Go Down

Topic: I need assistance with a project. (Read 1 time) previous topic - next topic


Thank you so much man! God, this is really one of the most helpful communities I've been a part of already! Now to make it slowly turn on. I'll post again if I run into anymore trouble.

Well I'd actually like you to see also post when you have good things to report not just your problems.  :D


Alright, now that it's working and I've tried on my own to make it slowly turn on and have failed, I'm turning to you again. I am assuming my code is far off. I don't know exactly how to make this argument. Here's what I got! I'l post a picture or video once I've got it installed!


Dec 05, 2012, 05:30 am Last Edit: Dec 05, 2012, 05:34 am by retrolefty Reason: 1
Ok not tested, but it compiles OK. Note that we are going to gradually turn on the led from full off to full on via PWM control of the led using analogWrite() commands. But pin 13 isn't one of the available PWM output pins, so we have to move the led to pin 10, and be sure to use a series resistor with the led. You can increase or decrease the speed of the ramping up of the LED by changing the value inside the delay(10) command.

Good luck;


Code: [Select]
const int buttonPin = 2;    
int PWMpin = 10; // LED in series with 470 ohm resistor on pin 10

int buttonState = 0;        

void setup() {
 pinMode(PWMpin, OUTPUT);      
 pinMode(buttonPin, INPUT);    

void loop(){
 buttonState = digitalRead(buttonPin);
 if (buttonState == HIGH) {        
     for (int i=0; i <= 255; i++){
          analogWrite(PWMpin, i);
 else {
   digitalWrite(PWMpin, LOW);

Go Up