Show Posts
Pages: [1]
1  Using Arduino / Programming Questions / Re: Simple LED Blink code, Kinda.... on: February 22, 2013, 10:42:21 pm
Hello again all, sorry for the delay as I have been busy with life...  smiley

So here is what I have so far. You guys have me on the right track for sure, but there are a few issues I can't figure out. When the switch is held High, the LED will blink(High then Low). When the switch is set to Low the Led will blink again, which in all honesty I kinda prefer however I would like to figure out how to just make it blink when the switch is set to High, then not blink again until the switch is cycled low then back to High again.

Any further assistance or hints into the right direction would be super appreciated... smiley-grin


int switch1 = 12;     // the number of the switch pin
int led1 =  4;      // the number of the LED pin

int prevState = LOW;
int currState;

void setup()
  // initialize the LED pin as an output:
  pinMode(led1, OUTPUT);
                             // initialize the switch pin as an input:
  pinMode(switch1, INPUT);     
void loop()
  currState = digitalRead(switch1);
  if (currState != prevState)
   digitalWrite(led1, HIGH);
   digitalWrite(led1, LOW);
  prevState = currState;

2  Using Arduino / Programming Questions / Re: Simple LED Blink code, Kinda.... on: February 04, 2013, 06:47:10 am
Blinks, Buttons..LOL. I will get the proper terminology down .. smiley-mr-green.. But yes for what I am doing a switch is the way to go, and how I am actually doing it.

I can see where you are going with this, I will give it a try and see how it goes.. Again, much appreciated.. smiley
3  Using Arduino / Programming Questions / Re: Simple LED Blink code, Kinda.... on: February 04, 2013, 05:52:10 am
Hello again, and thank you for the replies, much appreciated. Sorry for the vague blink description, I was trying to keep it light(no pun intended)  smiley-grin.. Anyway, what I mean by blink is an LED being high--delay--low..

Here is the code I am slowly modifying. It is the button example from the libraries. Once the button is engaged I want the LED to blink once, then stay low while that button is engaged. After the button is disengaged, then engaged again the LED will blink once, then back to where we were...

Thank you again.... smiley-cool


const int buttonPin = 2;     // the number of the pushbutton pin
const int ledPin =  13;      // the number of the LED pin

// variables will change:
int buttonState = 0;         // variable for reading the pushbutton status

void setup() {
  // initialize the LED pin as an output:
  pinMode(ledPin, OUTPUT);      
  // initialize the pushbutton pin as an input:
  pinMode(buttonPin, INPUT);    

void loop(){
  // read the state of the pushbutton value:
  buttonState = digitalRead(buttonPin);

  // check if the pushbutton is pressed.
  // if it is, the buttonState is HIGH:
  if (buttonState == HIGH) {    
    // turn LED on:    
    digitalWrite(ledPin, HIGH);
    digitalWrite(ledPin, LOW);
  else {
    // turn LED off:
    digitalWrite(ledPin, LOW);
4  Using Arduino / Programming Questions / Simple LED Blink code, Kinda.... on: February 03, 2013, 06:40:02 am
Hello all, great forum you have here. I am super impressed with the knowledge.. smiley-mr-green

So all I need is an LED(or series of) to blink upon receiving a high on one of the pins. Ok easy, now the part I can't figure out. The way I have the code written is similar to the button example, and I have the LED blinking however with that input staying high the arduino with continue to blink it. I would like the LED to blink, then go low while that input stays high. The input at some point will go low, and I would like the cycle to start again upon going high.. smiley-roll-sweat

FYI I am using an UNO.

Thank you all for the help and at least looking over my post, much appreciated... smiley
Pages: [1]