Pages: [1]   Go Down
Author Topic: New to the Forum  (Read 506 times)
0 Members and 1 Guest are viewing this topic.
Hertfordshire, UK
Offline Offline
Newbie
*
Karma: 0
Posts: 20
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi all,

I thought I'd say hi before posting any questions and introduce myself.

I'm brand new to Arduino and electronics, however I do have a Computer Science Degree so I've done a bit of programming in my past, that said I've not done any for about 12 years.

I'm planning on starting with the basics but as I spend most of my spare time flying model planes, I'm keen to see if I can move on to something motorised (on the ground) and then on to something capable of flying in the future.

I bought an Arduino Uno, a breadboard and a load of component LEDs and Resistors from Maplin so I'm playing with cycling LEDs via an array and getting my eye back in on the programming smiley

Many thanks in advance for advice received, in time I hope to be able to help others.

Dave
Logged

The Netherlands
Offline Offline
Edison Member
*
Karma: 51
Posts: 1729
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Dave, welcome.

Good news for you.
There's a quite large Arduino usergroup that also is into model flight stuff.
So you'll find that a lot of autopilot systems for mulitcopters are Arduino based.
However, being a starter myself, i'd advice to follow the examples you find with the IDE and right here on the forums.
Feel free to play around, and change those examples to do things just a little different and add or combine examples.
You'll have no problem "getting the hang of it".

You'll be programming your own stuff in no time.
Logged

Have a look at "blink without delay".
Did you connect the grounds ?
Je kunt hier ook in het Nederlands terecht: http://arduino.cc/forum/index.php/board,77.0.html

Hertfordshire, UK
Offline Offline
Newbie
*
Karma: 0
Posts: 20
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Cool, I was hoping that was the case  smiley

Thanks, I've already coded a knight rider light from scratch, then compared it to the one in the Playground and found my one much smoother as it uses Duty Cycle smiley  Is there a way of having it submitted to the Playground so others can make use of it?

Code:
// Dave Twilley 2012 (30/12/12)
// Cycles 6 LED's in a KITT Pattern using Pulse Width Modulation (PWM)
// In this example, three LED's will be lit all the time but at different
// Duty Cycles to give us a High, Medium and Low LED this makes the
// motion smoother and more realistic.
// We use an array to store the PINs we will be using and also to store
// Duty Cycle (PWM), of each PIN which will control the brightness of the
// LED

const int intSpeed = 250;                                                                // Delay between changing LED in ms
const byte byLEDCount = 6;                                                               // Number of LED's in use
const byte byHigh = 255;                                                                 // Set the High PWM value
const byte byMed = 30;                                                                   // Set the Med PWM value
const byte byLow = 10;                                                                   // Set the Low PWM value
boolean blDirection = false;                                                             // Set the initial direction of the lights, true = down the array

int arLED[byLEDCount][2] = {{11,0},{10,0},{9,0},{6,0},{5,0},{3,255}};                    // Define PWM PINs for LEDs as 11, 10, 9, 6, 5 & 3 plus define initial PWM
int intPosition = 6;                                                                     // Set the starting LED, this keeps track of the lead LED, ie. the brightest one

void setup()
{
  // Run through the array with a for loop and setup the PIN we wish to use on the Arduino
  for (byte loopCounter = 0; loopCounter < byLEDCount; ++loopCounter) {
    pinMode (arLED[loopCounter][0],OUTPUT);
  }
}

void loop()
{
   // Run through the array with a for loop and set the output PINS to the values found in the array
  for (byte loopCounter = 0; loopCounter < byLEDCount; ++loopCounter) {
    analogWrite (arLED[loopCounter][0],arLED[loopCounter][1]);
    if (arLED[loopCounter][1] == byLow) {arLED[loopCounter][1]=0;}                      // Test to see if this LED was on LOW before, if so, turn it off
    else if (arLED[loopCounter][1] == byMed) {arLED[loopCounter][1] = byLow;}           // Test to see if this LED was on MED before, if so, set it to LOW
    else if (arLED[loopCounter][1] == byHigh) {arLED[loopCounter][1] = byMed;}          // Test to see if this LED was on HIGH before, if so, turn it MED
  } // end for
 
  delay(intSpeed); //Delays for the timespecified in the global speed constant

  if (blDirection) {intPosition++;} else {intPosition--;}                               // If we're going down the array then incremement the position variable
  arLED[intPosition-1][1]=byHigh;                                                       // Set the LED to be the brightest in our array based on our current position
  if (intPosition == byLEDCount) {blDirection=false;} else if (intPosition == 1) {blDirection=true;}      // Check to see if we're at either end of the array, if we are reverse our direction
}

Dave
Logged

Pages: [1]   Go Up
Jump to: