Show Posts
Pages: [1] 2 3 4
1  Using Arduino / Programming Questions / Re: Make an led blink a specific amount of times in void-loop? on: April 02, 2014, 08:32:45 pm
OK thanks, I will try some things with the website.
2  Using Arduino / Programming Questions / Re: Make an led blink a specific amount of times in void-loop? on: April 02, 2014, 07:56:52 pm
Start with blink without delay. Add a variable which records the number of blinks that have been completed. Initialise this to zero in code which executes at the start of your blink sequence. Each time you complete a blink cycle, increment the count. If the count has reached the required number of blinks, don't perform any more blinks.

I am kinda bad at this... Could you please make a quick example sketch (just a few lines to clear that up)?
3  Using Arduino / Programming Questions / Re: Make an led blink a specific amount of times in void-loop? on: April 02, 2014, 07:16:31 pm
For this application, I need to have a buzzer and led blink 5 times when a toggle SWITCH (and not a button as I said earlier, sorry) is first toggled to the on position, after the 5 led/buzzer blinks, the led has to stay on continuously (that is until the switch is toggled again). So I would need the blink without delay... How should I proceed?
4  Using Arduino / Programming Questions / Make an led blink a specific amount of times in void-loop? on: April 02, 2014, 06:50:15 pm
How could I make an led blink a specific amount of times in the void-loop part of a sketch (Lets day 5 times when I first push a button)? I think I would have to use the button state detection sketch, but I don't understand it... Could someone explain it to me (or does anybody have a good link somewhere on the internet)?
Thank you!

Oh and here is the Arduino example sketch...
Code:
// this constant won't change:
const int  buttonPin = 2;    // the pin that the pushbutton is attached to
const int ledPin = 13;       // the pin that the LED is attached to

// Variables will change:
int buttonPushCounter = 0;   // counter for the number of button presses
int buttonState = 0;         // current state of the button
int lastButtonState = 0;     // previous state of the button

void setup() {
  // initialize the button pin as a input:
  pinMode(buttonPin, INPUT);
  // initialize the LED as an output:
  pinMode(ledPin, OUTPUT);
  // initialize serial communication:
  Serial.begin(9600);
}


void loop() {
  // read the pushbutton input pin:
  buttonState = digitalRead(buttonPin);

  // compare the buttonState to its previous state
  if (buttonState != lastButtonState) {
    // if the state has changed, increment the counter
    if (buttonState == HIGH) {
      // if the current state is HIGH then the button
      // wend from off to on:
      buttonPushCounter++;
      Serial.println("on");
      Serial.print("number of button pushes:  ");
      Serial.println(buttonPushCounter);
    }
    else {
      // if the current state is LOW then the button
      // wend from on to off:
      Serial.println("off");
    }
  }
  // save the current state as the last state,
  //for next time through the loop
  lastButtonState = buttonState;

 
  // turns on the LED every four button pushes by
  // checking the modulo of the button push counter.
  // the modulo function gives you the remainder of
  // the division of two numbers:
  if (buttonPushCounter % 4 == 0) {
    digitalWrite(ledPin, HIGH);
  } else {
   digitalWrite(ledPin, LOW);
  }
 
}
5  Using Arduino / Programming Questions / Re: How do I add 2 buttons with example sketch? on: March 05, 2014, 07:43:07 pm
What should I do now?
6  Using Arduino / Programming Questions / Re: Fireworks controller LED sketch HELP!!! on: March 05, 2014, 05:23:29 pm
I think I will order some relays, much simpler! Thanks for your help and time!
7  Using Arduino / Programming Questions / Re: Fireworks controller LED sketch HELP!!! on: March 05, 2014, 04:16:14 pm
I will explain:

As I mentioned, I am building a fireworks controller like this one http://www.instructables.com/id/Fireworks-Controller/
On the controller, there is a SPDT switch that activates either it's test or armed mode. I want to add a buzzer to it so I can have audio cues when it is: Turned on (in the void setup, when the chip will receive power), put in armed mode, and finally in test mode. The controller runs on a 12volt battery (or power adapter). I will put the final code (if ever I succeed) on an Attiny85 chip powered by a 5 volt regulator connected to the power source.

I want to add one wire to each of the three terminals on the SPDT switch, so the Arduino can detect when the armed and test modes are activated. I cannot connect the wires directly to the Arduino, because this would damage it. Would it be simpler to use some relays? I already have some transistors on hand, but no relays. I would have to order some.

I hope that clears it up.

8  Using Arduino / Programming Questions / Re: How do I add 2 buttons with example sketch? on: March 05, 2014, 03:34:17 pm
Yeah, I deleted one of the curly brackets from the bottom and I don't have the error anymore.
9  Using Arduino / Programming Questions / Re: How do I add 2 buttons with example sketch? on: March 05, 2014, 03:10:25 pm
Ok, I ran the auto-format again and I just saw the exact same warning. What does it mean....
10  Using Arduino / Programming Questions / Re: Fireworks controller LED sketch HELP!!! on: March 05, 2014, 03:08:04 pm
Well the thing is, there are technically two loads. I want to use the transistor kind-of as a relay, so the arduino can read the switch's state without getting damaged (because the switch is connected to 12 volts). So the load is the switch's power (12volts).
11  Using Arduino / Programming Questions / Re: How do I add 2 buttons with example sketch? on: March 04, 2014, 05:04:12 pm
I tried auto-format and it didn't say/do anything.
12  Using Arduino / Programming Questions / Re: How do I add 2 buttons with example sketch? on: March 04, 2014, 04:34:34 pm
I added it to my code, and I now have this:
Code:
byte buttonState1 = 0;
const byte switch1 = 2;
const byte buzzer = 10;
int led = 13;
 


void setup() {               
 
  pinMode(led, OUTPUT);
  pinMode(buzzer, OUTPUT);     
  pinMode(switch1, INPUT_PULLUP); 
  pinMode(switch2, INPUT_PULLUP);
 
  void buzzer() {
  digitalWrite(10, HIGH);
}

 
  digitalWrite(buzzer, HIGH);   // turn the LED on (HIGH is the voltage level)
  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(250);               // wait for a second
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(250);               // wait for a second 
  digitalWrite(buzzer, LOW);   // turn the LED on (HIGH is the voltage level)  // wait for a second 
 
 
}


void loop() {

 
 buttonState1 = digitalRead(switch1);

  if (buttonState1 == LOW)
  {     
       buzz(5);         
  }
}

void buzz(int 2)
{
  for (int i = 0; i < 2; i++)
  {
    digitalWrite(buzzerPin, HIGH);
    delay(300);               
    digitalWrite(buzzerPin, LOW);
    delay(300);     
  }
}


}

It gives me the following error concerning "int led = 13":
Quote
expected ',' or '...' before numeric constant         
How do I fix this?
13  Using Arduino / Programming Questions / Re: Fireworks controller LED sketch HELP!!! on: March 04, 2014, 04:05:58 pm
Anyone?
14  Using Arduino / Programming Questions / Re: Fireworks controller LED sketch HELP!!! on: March 04, 2014, 09:33:46 am
Is this how the transistor switch should look like?

Here is the schematic:  https://mega.co.nz/#!JotBGDzY!o0UywI9fCKQWd6JizxWgmotlj_o3gxmhAOM8biNLCYw

From left to right: Switch with the power it controls/ Transistor (NPN 2N3904)/  Arduino board pin and ground.
15  Using Arduino / Programming Questions / Re: How do I add 2 buttons with example sketch? on: March 03, 2014, 01:15:31 pm
Ah ok, I will try that! Thanks a lot!
Pages: [1] 2 3 4