My first Arduino art (5led on/off example source)

The advantage of Arduino is beginners can access electrical and electronic experiment easily.
I think the reason is the arduino support abundant examples  and functions.
Nervertheless I don't know ATmega, I could led on/off easily.

This is demo video and picture.
To experiment my case, you need arduino board, resistance 220om and led.

And to setup your arduino is explained very well on the homepage.
http://arduino.cc/en/Guide/HomePage
http://arduino.cc/en/Guide/Windows





Thank you.



source code
/*
  Blink
  Turns on an LED on for one second, then off for one second, repeatedly.

  This example code is in the public domain.
 */

// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 13;
int mode=0;
int order=1;
int count=0;

// the setup routine runs once when you press reset:
void setup() {               
  // initialize the digital pin as an output.
  pinMode(led, OUTPUT);
  pinMode(led-1,OUTPUT); 
  pinMode(led-2,OUTPUT);
  pinMode(led-3,OUTPUT);
  pinMode(led-4,OUTPUT);
      
}

// the loop routine runs over and over again forever:
void loop() { 

  if(mode == 0)
    count = count+1;
  else
    count = count-1;

  for(int i=0; i< 5 i=i+1) {
    if(count%5 == i)
      digitalWrite(led-i, HIGH);   // turn the LED on (HIGH is the voltage level)     
    else
      digitalWrite(led-i, LOW);   // turn the LED on (HIGH is the voltage level)   
  }
  delay(200);

  if(mode == 0)
  {
    if(count == 50)     
      mode=1;
  }else{
    if(count == 0)
      mode=0;   
  } 
}

Comments

Popular posts from this blog

(OpenCV Study) Background subtractor MOG, MOG2, GMG example source code (BackgroundSubtractorMOG, BackgroundSubtractorMOG2, BackgroundSubtractorGMG)

OpenCV Stitching example (Stitcher class, Panorama)

Example source code of extract HOG feature from images, save descriptor values to xml file, using opencv (using HOGDescriptor )

Real-time N camera stitching Class.

Optical Flow sample source code using OpenCV

OpenCV Drawing Example, (line, circle, rectangle, ellipse, polyline, fillConvexPoly, putText, drawContours)

Video Stabilization example source code, (using cvFindHomography, cvWarpPerspective functions in openCV)

SICK LMS511 sensor data acquisition interface (source code, C++/MFC)

8 point algorithm (Matlab source code) / The method to get the Fundamental Matrix and the Essential matrix

Image warping (using opencv findHomography, warpPerspective)