PVC Arsenal 17 wrote: @Zeus: I was always turned off by electronics until I saw some really cool things done with them recently. Then I found Arduino and it really can't get any easier than this. Hopefully after I get this working more people here will want to try similar things. It's not too expensive and the possibilities are almost endless. I'm really tempted to put a small airsoft gun on my BOE Bot too.
I was turned off for a while too.. Im actually just getting into it, but I have seen some examples and it seems very simple...
you have some plug ins and some plug outs on this arduino... you can set up a simple switch to send power to the plugin..
so if you flip a switch, it sends power to a plugin.. you can hook up the arduino to your computer via USB and write a program that checks to see if power is coming in on that plugin...
if power is coming in on that plugin, you can send power out every 2 seconds out plug-out 3...
plug-out 3 sends power to led..
so every time that switch is turned on.. power is sent to that led that blinks every 2 seconds...
now thats really laymen terms as the plug in and plug outs are pins, but you get the idea..
the programming for it is really simple too..
the best part is the arduino is only $30... and has a bunch of pins including PWM pins! so the possibilites are endless.. home automation, circuit for a spudgun (my next project), etc...
for example here is a quick program I made real quick..
Code: Select all
int switchPin = 3; // Momentary Switch connected to pin 3
int ledPin = 13; // LED connected to digital pin 13
void setup()
{
pinMode(ledPin, OUTPUT); // sets the digital pin as output
pinMode(switchPin, INPUT); // sets the digital pin as the input
}
void loop()
{
if(digitalRead(switch) == HIGH) { // if he switch has been turned on...
digitalWrite(ledPin, HIGH); // sets the LED on
delay(1000); // waits for a second
digitalWrite(ledPin, LOW); // sets the LED off
delay(1000); // waits for a second
} // end of if statement
}// end of loop
Loop runs constantly while the arduino is on...
so every millisecond, it runs whatever is inside loop untill whatever is inside the loop is finished, then the loop runs again.. the if statement is inside the loop.
so every millisecond it runs the loop to see if power is coming from the momentary switch.. if power is coming from the switch, it sends power out to an LED, once that is done, it runs whatever is inside the loop again... so if you repeat that process.. it basically means you hold the trigger down on the gun, and it fires once every second until you let go of the trigger (trigger is a momentary switch...)
it is that simple...
Up above outside of the loop is just declaring those pins and what they do essentially...